GenericServlet Vs HttpServlet

When do we opt GenericServlet?When do we opt HttpServlet(i know if protocol is HTTP, any other reasons)?
[111 byte] By [kalpanava] at [2007-11-27 8:40:09]
# 1

GenericServlet belongs to javax.servlet package

GenericServlet is an abstract class which extends Object and implements Servlet, ServletConfig and java.io.Serializable interfaces.

The direct subclass to GenericServlet is HttpServlet.It is a protocol-independent servlet.

To write a GenericServlet you need abstract service() to be overridden.

HttpServlet:

HttpServlet belongs to javax.servlet.http package

This is an abstract class which extends GenericServlet and implements java.io.Serializable

A subclass of HttpServlet must override at least one method of doGet(), doPost(),doPut(), doDelete(), init(), destroy(), getServletInfo()

Generic servlets works for every protocal and Http servlet works for only Http protocol.

HttpServlet is a protocol dependent whereas GenericServlet is protocol independent

The servlet that gets invoked with Common Gateway Interface protocol is known has Generic Servlet. Limitation: Request Replication.The servlet that is invoked by HTTP protocol is know as HTTP Servlet.Advantage: It don't replicate the request.

i hope , these explanations is enough to understand Generic Servlet vs HTTp servlets..

drvijayy2k2a at 2007-7-12 20:38:28 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...