How many types of servlet in Java?

Generic Servlet

  • Protocol independent. It can handle all types of protocols like http, ftp, smtp.
  • Class is direct subclass of servlet interface.
  • It is an abstract class which implements servlet, servlet config interfaces.
  • Contains service method.
  • implements servlet config and way to accept initialization param passed to servlet from xml.

Http Servlet

  • Protocol dependent supports only http.
  • Direct subclass of generic servlet.
  • It is an abstract class which extends generic servlet and implements java.io.serializable
  • uses doGet, doPost and doDelete methods
  • Public void service and protected void service.