The main difference between GenericServlet and HTTPServlet are as follows:
Generic Servlet | Http Servlets |
GenericServlet defines a generic, protocol-independent servlet which can be used to any protocol. | HttpServlet defines a HTTP
protocol specific servlet and implements the GenericGervlet. |
GenericServlet gives a blueprint and makes writing servlet easier and efficient. | HttpServlet gives a blueprint for Http servlet and makes writing them easier for http protocol only. |
GenericServlet provides
simple versions of the lifecycle methods init and destroy and of the methods
in the ServletConfig interface. |
HttpServlet extends the
GenericServlet and hence inherits the properties GenericServlet. |
GenericServlet implements the log method, declared in the ServletContext interface. | |
To write a generic servlet, it is sufficient to override the abstract service method no need to overide other methods like doGet and doPost. |