What is Generic Servlet and how it is different from Http
Servlet?

Answer Posted / qim2010

Both these classes are abstract but the differences are

A GenericServlet has a service() method to handle
requests.
The HttpServlet extends GenericServlet and adds support
for HTTP
protocol based methods like doGet(), doPost(), doHead()
etc. All
client requests are handled through the service() method.
The service method dispatches the request to an appropriate
method like doGet(), doPost() etc to handle that request.
HttpServlet also has methods like doHead(), doPut(),
doOptions(),
doDelete(), and doTrace().


GenericServlet is Protocol independent. GenericServlet is
for servlets
that might not use HTTP (for example FTP service).
But HttpServlet is protocol dependent (i.e. HTTP).

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of servletconfig interface?

556


What is servlet lazy loading?

695


Can filter be used as request or response?

540


What is the inter-servlet communication?

700


What do you mean by servlet?

719






How do we go with database connection and log4j integration in servlet?

702


Why the concept of single thread model interface is used?

553


What are some disadvantages of storing session state in cookies?

588


How do you invoke a Servlet? What is the difference between doPost method and doGet method?

644


Are Servlets Thread Safe? How to achieve thread safety in servlets?

559


Which exception is thrown if the servlet is not initialized properly?

588


What is servlet in web technology?

577


What are the type of protocols used in httpservlet?

612


What is servlet and how it works?

508


What is a web application and what is it’s directory structure?

584