Demo Servlet by Implementing Servlet Interface directly.
public class FirstServlet implements Servlet{
static
{
System.out.println(“Servlet
class loading”);
}
public FirstServlet()
{
System.out.println(“Servlet
Instantiation”);
}
public void init(ServletConfig config )
{
System.out.println(“Servlet
init method called”);
}
Public void service(ServletRequest req, ServletResponse resp)
throws IOException , ServletException{
System.out.println(“Servlet method got called”);
PrintWriter out=res.getWriter();
out.println(“Welcome
to Service method”);
}
public void destroy()
{
System.out.println(“Servlet
destroy method called”);
}
Public ServletConfig getServletConfig()
{
return null;
}
Public String getServletInfo()
{
return “this is servlet example”;
}
}
0 comments :
Post a Comment