> Can you please enlighten me of what is the difference between Generic
> Servlet and HttpServlet.
The differance between the two is that HttpServlet is a servlet which is a
specialized version of the Generic Servlet to handle the Http protocol and
has convinience methods/classes related to it in the javax.servlet.http
pacakage.
The Generic Servlet is an abstract class. It is there to define the frame
work for use of servlets. Generic Servlet has to be extended as per the
protocol you wish to use it for. As for the HTTP protocol, sun has already
done the work for you.
> Ok let me first tell you of my understanding.. when your servlet extends
> Generic Servlet the life cycle is init(), service(), destroy()......
That is correct. Its the same for all servlets.
>and if
> it extends HttpServlet the life cycle is init(), doGet(), doPost(),
> destroy()......
This is wrong. For HttpServlet also it is init(), service(), destroy().
> How is our servlet which extends HttpServlet , invoke the doGet() method,
if
> the client request is get. and how is the doPost() method is invoked if
the
> client request is post....
All request to any servlet is passed to it's Service method. Period.
Now it is up to the service method how to handle the request.
The HttpServlet class has an implementation of the service method which
takes the request, finds out the method used in the HTTP request ( Get,
Post, Head, Put...) and passes control to the corresponding doXXX method
with the appropriate request and response objects.
So for a request which is Get the control will be
httpServlet.service ---> httpServlet.doGet
> can the same be achieved with a servlet which extends Generic Servlet.
The httpServlet achieves this and it extends the Generic Servlet. The
Generic Servlet is there to define the frame work and not do any meaningful
work on its own. That is why it is abstract.
> regards
> Chandra Shekar
Gokul
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html