Servlet Types
There are mainly two types of servlets -
- Generic Servlet - Generic servlet is protocol independent servlet. It implements the Servlet and ServletConfig interface. It may be directly extended by the servlet. Writing a servlet in in GenericServlet is very easy. It has only init() and destroy() method of ServletConfig interface in its life cycle. It also implements the log method of ServletContext interface.
- Http Servlet - HttpServlet is HTTP (Hyper Text Transfer Protocol ) specific servlet. It provides an abstract class HttpServlet for the developers for extend to create there own HTTP specific servlets. The sub class of HttpServlet must overwrite at least one method given below- doGet(),doPost(),doTrace(),doDelete(),init(),destroy(),getServiceInfo().
There is no need to
overrride service() method. All the servlet either Generic Servlet or Http
Servlet passes there config parameter to the Servlet interface.
![]() |
Servlet Heirarchy |
Comments
Post a Comment