In addition to Mark's comments.
Since the init() method is an instance method (not static) one has to make
an assumption that it can be called once for each instance. However I would
like to believe that it will be called no more than once for a particular
instance.
Filip
----- Original Message -----
From: "Marc Saegesser" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, December 28, 2000 12:49 PM
Subject: RE: Init() being called 3 times
> In Tomcat 3.2.x, specifying more than one name for a servlet in web.xml
> causes a separate instance to be created for each name and each instances
> init() method will et invoked. Essentially creating a new servlet for
each
> name as opposed to multiple names for a single instance of the servlet.
>
> The Servlet 2.2 spec (at least by my reading) doesn't provide clear
guidance
> on the real behaviour of the <servlet-name> tag and the behaviour may vary
> from one servlet container to another. I seem to recall that JRun, for
> example, didn't create multiple instances.
>
> -----Original Message-----
> From: David Fusari [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 28, 2000 12:51 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Init() being called 3 times
>
>
> I have seen the same thing, it does not appear that init is called twice
but
> that you get 2 instances of the servlet loaded. Perhaps something to do
> with aliases. My work around was to not specify a context in server.xml
but
> only specify the servlet mapping in my web.xml.
>
> David.
>
> -----Original Message-----
> From: Marc Saegesser [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 28, 2000 1:46 PM
> To: [EMAIL PROTECTED]
> Subject: RE: Init() being called 3 times
>
>
> 1) Set Tomcat's debug level to something big (say 20).
> 2) Add a System.out.println() call to the begin and end or your init()
> method. Include a timestamp.
> 3) Add a call to Thread.currentThread().dumpStack() to the start of your
> init() method.
> 4) Post the output here.
>
> It is extremely unlikely that the servlet container is calling init() more
> than once, but there is no way to diagnose the problem without more
> information.
>
> -----Original Message-----
> From: Shahed Ali [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 28, 2000 10:23 AM
> To: [EMAIL PROTECTED]
> Subject: Init() being called 3 times
>
>
> Hi,
>
>
> I am loading a servlet on startup. In the init(), I have a setting some
> system properties, and
> doing some logging.
>
> When I inspect the logs, its seems that the init method is called exactly
3
> times.
>
> Any idea whats going on ?
>
> I am using Tomcat 3.2.1 w/Apache 3.1.14 on Solaris 8 Intel w/JDK 1.3
>
> Thanks
> Shahed.