Tuesday, 15 July 2014

Servlet Interface

All Servlets implement this interface either directly or indirectly.

public interface Servlet {
 public void init(ServletConfig config) throws ServletException;
 public ServletConfig getServletConfig();
 public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException;
 public String getServletInfo();
 public void destroy();
}

GenericServlet and HttpServlet are the two classes in Servlt API, that implements Servlet interface. For most of the purposes Developers extend the HttpServlet class. A protocol independent servlet should extends GenericServlet, while an HttpServlet should extends HttpServlet class.

Servlet interface defines the methods to initialize a servlet, to process request, and to remove a servlet from the server.


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment