You can write your own servlet which extends HttpServlet and make it abstract.
Override the init and doPost methods and declare them as final. You can put your
initialization code in the init method and call one start method which will be
overridden by all other servlets which extends your servlet instead of
HttpServlet. Similarly you can call a method called handleRequest in doPost and
make doPost final. All your servlets will be overriding handleRequest.
The main advantage in this design is all your common functionalities can be
implemented in your abstract servlet.
-RVS
Bruce Bantos wrote:
> I am trying to subclass a base servlet that handles authentication, to make
> sure that any servlet that subclasses the base servlet is forced to log in
> if a session object is not found. Can anyone give me an example, even a very
> general one? I have tried to do this previously, but the way I did it was to
> pass the HttpServlet Request, Response, and my session object to an
> authentication method in my base class. This meant that I had to call the
> authentication method in my doGet, doPost for every servlet. I want do find
> a way to do this automatically, so there is no chance of forgetting to put
> that call to the base class in. Thanks!
>
> -Bruce
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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