ECTED]>
13/02/2001 05:26
Please respond to tomcat-user
To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
cc:
Subject: RE: Using a servlet superclass
Well no simple solutions will do exactly what you want. There is not
Hi,
A quick comment on this technique. You must be careful when setting variables
in the childClass if you call the init method from the constructor. For example
the following code produces unexpected results:
class Child extends Parent {
int value1 = 0;
int value2;
public void ch
Well no simple solutions will do exactly what you want. There is nothing
special about the init method in java. It might be nice if the servlet
container promised to walk up the class hierachy calling each init as it
goes but thats not how it works.
But you could;
1.Use the java debugging inter
> I have a number of servlets in my application that need to
> perform common initialisation, etc. So I was thinking of
> creating a superclass that has an init method that does all
> of the common work, eg.,
...snip...
> This seems to be OK, until I implement init in the
> WorkerServlet, as the
the same way as
constructors work in ordinary classes, but I can see that's just
not going to happen ...
Jill
> From: CPC Livelink Admin
> Subject: RE: Using a servlet superclass
> Date: Sun, 11 Feb 2001 17:54:09 -0800
>
>
> Yes.
>
> Have your WorkerServlets
Perhaps this will work, though I am not so certain of the life cycle of a
servlet to say for sure:
Define the default (i.e. no argument) constructor for SuperServlet (its
signature is: SuperServlet() ) within which you call init. Any child of
SuperServlet should then automagically call init (or a
Yes.
Have your WorkerServlets implement a procedure called childInit or
something, which is basically an empty procedure in the SuperServlet. Then
call this function as the last (or first) call of the SuperServlet init
function. This is much like how GenericServlet makes init() a convenience
ca