Servlets
Tomcat uses catalina container. there are also other servers to deploy out applications like Weblogic, Glassfish etc.
Servlet interface contains five abstract methods which describes the servlet life cycle. These methods will be part of servlet actions.
1. public void init(ServletConfig config)
2. public void service(ServletRequest request, ServletResponse response)
3. public void destroy()
4. public ServletConfig getServletConfig()
5. public String getServletInfo()
In order to make normal class work like a Servlet, that class should implement Servlet interface and that class should implement all the five method.
here the thing is we actually write the server logic processing code in service() method. So GenericServlet Abstract class provides the implementation for remaining 4 methods and it will make the service method as Abstract
and GenericServlet class implements Servlet, Sereizeiable, ServletConfig interfaces and who so ever wants their class to work like Servlet can extend GenericServlet abstract class and can provide the implementation only for service method.
Comments
Post a Comment