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

How a servlet is unloaded?

585


What is the difference between using getSession(true) and getSession(false) methods?

562


What is cookie in servlet?

586


What do you mean by httpservlet?

557


What is pure servlet?

691






Which httpsession object is used to view and manipulate information about a session?

721


What do you mean by filter in servlet?

532


What is the use of attribute in servlets?

533


What is servlet and list its types?

536


What is the directory structure of web application?

518


What is war file?

571


What's the architecture of a servlet package?

551


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

578


What is the disadvantage of cookies?

565


Describe in brief RequestDespatcher?

586