top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the difference between GenericServlet and HttpServlet ?

+2 votes
674 views
What is the difference between GenericServlet and HttpServlet ?
posted Jan 30, 2015 by Deepan

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+2 votes
 
Best answer

Generic Servlet:

 1. GenericServlet class is direct subclass of Servlet interface.

 2. Generic Servlet is protocol independent.It handles all types  of protocol  like http, smtp, ftp etc.

 3. Generic Servlet only supports  service() method.It handles only simple request 
    public void service(ServletRequest req,ServletResponse res ).

 4. Generic Servlet only supports  service() method.

HttpServlet:

 1. HttpServlet class is the direct subclass of Generic Servlet.

 2. HttpServlet is protocol dependent. It handles only http protocol.

 3. HttpServlet  supports public void service(ServletRequest req,ServletResponse res ) and protected void    
     service(HttpServletRequest req,HttpServletResponse res).

 4. HttpServlet supports also   doGet(),doPost(),doPut(),doDelete(),doHead(),doTrace(),doOptions()etc.
answer Feb 2, 2015 by Karthick.c
+1 vote
  • HTTPServlet is protocol specific (HTTP) while GenericServlet is not.
  • GenericServlet has service() method not doGet() and doPost kind of, but HTTPServlet has these all
answer Feb 1, 2015 by Garima Gupta
...