Difference Between GenericServlet and HttpServlet?

Difference Between GenericServlet and HttpServlet?

Generic Servlet:
  • GenericServlet class is direct subclass of Servlet interface.
  • Generic Servlet is protocol independent.It handles all types  of protocol  like http, smtp, ftp etc.
  • Generic Servlet only supports  service() method.It handles only simple request 
    public void service(ServletRequest req,ServletResponse res ).
  • Generic Servlet only supports  service() method.
HttpServlet:
  • HttpServlet class is the direct subclass of Generic Servlet.
  • HttpServlet is protocol dependent. It handles only http protocol.
  • HttpServlet  supports public void service(ServletRequest req,ServletResponse res ) and protected void service(HttpServletRequest req,HttpServletResponse res).
  • HttpServlet supports also   doGet(),doPost(),doPut(),doDelete(),doHead(),doTrace(),doOptions()etc.

No comments:

Post a Comment