HelloHome.html
<html><head><title>My Home Page</title></head>
<body>
<h1>Hi,Iam in client side</h1>
<a href="Testingservlet"><h1><b>Click me to take you to server side<b></h1></a>
</body>
</html>
Testingservlet.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Testingservlet extends HttpServlet{
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
response.setContentType("text/html;charset=UTF-8");
PrintWriter out=response.getWriter();
out.println(“Welcome !!!!!Your are in server side!");
out.close(); // Always close the output writer
}
}
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaeeweb-app_3_0.xsd">
<servlet>
<servlet-name>Testingservlet</servlet-name>
<servlet-class>Testingservlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Testingservlet</servlet-name>
<url-pattern>/Testingservlet</url-pattern>
</servlet-mapping>
</web-app>
No comments:
Post a Comment