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 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.


  1. thanks all for valuable feedback

  2. Hi

    Does GenericServlet have Stateless Nature or Stateful Nature?
    As i know HttpServlet does have a stateless Nature due to http protocol?

    Please guide me as i am a new bee in servlet..

  3. Hi it depends which type of protocol is being used with GenericServlet class as it is protocol independent and we can send request to GenericServlet class Using HTTP, FTP and SMTP.

  4. Hi
    In GenericServlet class we can also use
    service(HttpServletRequest request, HttpServletResponse response)
    I have seen examples using service methods as is
    is it true ??

    1. It is not correct to use httpservlet request & response in generic servlet

  5. very Good man, thanks any doubts cal to this number i am all so S\w Engg. java develaper pls cal to me , this is my number(9154421946. AP, india

  6. avax.servlet.GenericServlet
    Signature: public abstract class GenericServlet extends java.lang.Object implements Servlet, ServletConfig, java.io.Serializable

    GenericServlet defines a generic, protocol-independent servlet.
    GenericServlet gives a blueprint and makes writing servlet easier.
    GenericServlet provides simple versions of the lifecycle methods init and destroy and of the methods in the ServletConfig interface.
    GenericServlet implements the log method, declared in the ServletContext interface.
    To write a generic servlet, it is sufficient to override the abstract service method.
    Signature: public abstract class HttpServlet extends GenericServlet implements java.io.Serializable

    HttpServlet defines a HTTP protocol specific servlet.
    HttpServlet gives a blueprint for Http servlet and makes writing them easier.
    HttpServlet extends the GenericServlet and hence inherits the properties GenericServlet.

  7. core java, jdbc, jsp,servlet,spring, web services Hibernate, struts

  8. nice answer

  9. Good Explanation................

  10. However there are some exemptions for which the landowner will not be held accountable, such
    as: any kind of flue which is connected to the gas appliance which is owned personally by the
    landowner or by the tenant. The driver's licensing exams in all stated require that drivers pass a vision test, but
    they do nothing to test for reaction speed. It helps an individual in knowing the amount he has
    to pay or expect while buying or selling the real estate respectively.

    Stop by my web page; newspaperarchive

  11. though GenericServlet is protocol-independent servlet, so can we call a GenericServlet using SMTP or FTP, etc protocalls..?

  12. thnks to all .............v good ans.

  13. not bad why we are using doXXX() methods

  14. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training India . Nowadays Java has tons of job opportunities on various vertical industry.

  15. I wish to show thanks to you just for bailing me out of this particular
    trouble.As a result of checking through the net and meeting
    techniques that were not productive, I thought my life was done.

    java Training in Bangalore

    java training in chennai


  16. The information that you shared with us is very useful and thanks for sharing. Also, many thanks for permitting me to comment!

    Quicken Support Number

    Quicken Online Support Number

    Quicken tech Support Number

    HP Support Number

  17. Very interesting content which helps me to get the indepth knowledge about the technology. To know more detils about the course visit this website.
    JAVA Training in Chennai
    Best JAVA Training in Chennai
    Android Training in Chennai
    Loadrunner Training in Chennai
    French Classes in Chennai

  18. Visit us at BGAOC and good luck will smile at you a casino online top Win now or never.

  19. Где можнокупить диодную ленту что бы хорошего качества и по нормальной цене, лучшее что я находил это в ekodio, отличная контора