aspose file tools*
The moose likes Servlets and the fly likes Servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet" Watch "Servlet" New topic
Author

Servlet

Prashanth Bhanu
Ranch Hand

Joined: Sep 25, 2003
Posts: 110
HI Friends,
A basic question on servlet.We have GenericServlet class and is declared as a Abstract class,
We have one more class httpServlet is again an Abstract class which extends our Generic Servlet class.So it is learnt that what all classes extends httpServlet class, must implement atleast any one of the methods listed below.
doGet
doPost
doPut
doDelete
init
getServletInfo
My doubts are
1)Why GenericServlet is declaed as abstact as it has no single method as abstract?
2)How does the rule applied on httpServlet class as what all classes extends this class must
implement atleast one of the above methods?
thanks in advance for helping me to know the hidden strategy
prashanth
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

1)Why GenericServlet is declaed as abstact as it has no single method as abstract?
Becuase it's not meant to be used directly. The intent is for it to be extended.


2)How does the rule applied on httpServlet class as what all classes extends this class must
implement atleast one of the above methods?

You don't have to implement any of those methods. They're all implemented for you. You could certainly write and compile a servlet with none of those methods in it. It just wouldn't do anything.

You'll want to override one of those methods if you intend to have it do some work for you.

Think of the HttpServlet as a template with all the heavy lifting already done for you.

thanks in advance for helping me to know the hidden strategy

There's nothing hidden about it. It's all publicly documented in both the
API and in the Servlet Spec.
[ February 16, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet
 
Similar Threads
Basic Servlet Doubt
Implementing methods from HttpServlet
Why HttpServlet also implements Serializable?
Method of javax.servlet.Servlet
Where does ServletContect come in the hierarchy ?