postheadericon create GenericServlet

Step 1 :  Create .java File using text editor


import javax.servlet.*;
import java.io.*;
import javax.servlet.annotation.WebServlet;
@WebServlet(
  name="WTAD",
  urlPatterns={"/Ex10","/index.html","/BipinRupadiya.blogspot.com"}
)
public class GenricServletDemo extends GenericServlet
{
 public void service(ServletRequest request, ServletResponse response)
  throws ServletException,IOException
 {
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  out.println("<html><head><title>WTAD</title></head> <body>");
  String str="<h1>
welcome to </h1>
";
  str=str+"<br />www.bipinrupadiya.blogspot.com";
  out.println(str);
          out.println("</body> </html>");
 }
}




Step 2 :  Go to Command prompt and compile it




Step 3 :  Create Web Application structure and upload your .class / servlet file  on  server




Step 4 :  Create web.xml 



Step 4 :  Explore your servlet

http://hostname/appName/my-address                http://localhost:8081/bipin/wtad/bsr.co.in

n  Protocol
n  Custom URL for servlet
n  Web Application name
n  Host / domain name

Step 4 :  output of servlet on Firefox

 




0 comments:

Follow by Email

Blog Archive

Total Pageviews

© BipinRupadiya.com. Powered by Blogger.