You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Nencho Lupanov <ne...@googlemail.com> on 2007/04/11 12:47:03 UTC

Servlet init method invocation

Hi All,

I am trying to understand, when is the Servlet init() method invoked in
tomcat.
I expected it to be executed after succesfull deployment but it seems that
it is
executed the first time(only)  when request arives.
So, i need to receive a request in order this method to be executed?
Is that configurable?Thanks.

Nencho

Re: Servlet init method invocation

Posted by Rashmi Rubdi <ra...@gmail.com>.
I think ServletContextListener is useful for initializing non-Servlet
classes too, the non-Servlet class only needs to implement the
listener.

-Rashmi

On 4/11/07, Mikolaj Rydzewski <mi...@ceti.pl> wrote:
> I prefer to use ServletContextListener.

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Servlet init method invocation

Posted by Mikolaj Rydzewski <mi...@ceti.pl>.
Nencho Lupanov wrote:
> I am trying to understand, when is the Servlet init() method invoked in
> tomcat.
> I expected it to be executed after succesfull deployment but it seems 
> that
> it is
> executed the first time(only)  when request arives.
> So, i need to receive a request in order this method to be executed?
> Is that configurable?Thanks.
I prefer to use ServletContextListener.


-- 
Mikolaj Rydzewski <mi...@ceti.pl>


Re: Servlet init method invocation

Posted by Nencho Lupanov <ne...@googlemail.com>.
I used load-on-startup and it works fine.

Thanks,
Nencho


2007/4/11, David Delbecq <de...@oma.be>:
>
> init() is called when servlet is initialized. The servlet is, by default
> (see j2EE specs) initialized when it is first accessed. The
> 'load-on-startup' element of web.xml can be used to force servlet to be
> initialized upon webapp startup. The value of this element is a number
> that specify order, compared to other servlet, in which it is initialized.
>
> En l'instant précis du 11/04/07 12:47, Nencho Lupanov s'exprimait en ces
> termes:
> > Hi All,
> >
> > I am trying to understand, when is the Servlet init() method invoked in
> > tomcat.
> > I expected it to be executed after succesfull deployment but it seems
> > that
> > it is
> > executed the first time(only)  when request arives.
> > So, i need to receive a request in order this method to be executed?
> > Is that configurable?Thanks.
> >
> > Nencho
> >
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: Servlet init method invocation

Posted by David Delbecq <de...@oma.be>.
init() is called when servlet is initialized. The servlet is, by default
(see j2EE specs) initialized when it is first accessed. The
'load-on-startup' element of web.xml can be used to force servlet to be
initialized upon webapp startup. The value of this element is a number
that specify order, compared to other servlet, in which it is initialized.

En l'instant précis du 11/04/07 12:47, Nencho Lupanov s'exprimait en ces
termes:
> Hi All,
>
> I am trying to understand, when is the Servlet init() method invoked in
> tomcat.
> I expected it to be executed after succesfull deployment but it seems
> that
> it is
> executed the first time(only)  when request arives.
> So, i need to receive a request in order this method to be executed?
> Is that configurable?Thanks.
>
> Nencho
>


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Servlet init method invocation

Posted by David Smith <dn...@cornell.edu>.
Nencho Lupanov wrote:

> Hi All,
>
> I am trying to understand, when is the Servlet init() method invoked in
> tomcat.
> I expected it to be executed after succesfull deployment but it seems 
> that
> it is
> executed the first time(only)  when request arives.
> So, i need to receive a request in order this method to be executed?
> Is that configurable?Thanks.
>
> Nencho
>
By default, probably.  There is also a <load-on-startup> element in 
web.xml defined on a per servlet basis to force load the servlet when 
tomcat starts.

--David

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org