You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by lightbulb432 <ve...@hotmail.com> on 2007/06/09 19:30:15 UTC

ServletContextListener

Can requests potentially arrive at a servlet before the
ServletContextListener's contextInitialized method has completed? I ask
because the method occurs as a notification once the servlet context is
ready to accept requests. Is there a chance, then, that a request could
begin being served while your contextInitialized method is being carried out
(especially if it's long-running)?

Is contextInitialized suitable only for things like logging the fact that a
context is ready, or can it be used for setup that MUST occur before the
first request is accepted? If not the latter, what can be used to serve this
function?
-- 
View this message in context: http://www.nabble.com/ServletContextListener-tf3894944.html#a11042104
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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: ServletContextListener

Posted by Lakshmi Venkataraman <la...@foundrynet.com>.
 -----Original Message-----
From: lightbulb432 [mailto:veerukrishnan@hotmail.com] 
Sent: Saturday, June 09, 2007 10:30 AM
To: users@tomcat.apache.org
Subject: ServletContextListener


>Can requests potentially arrive at a servlet before the
ServletContextListener's contextInitialized method has 
>completed? I ask because the method occurs as a notification once the
servlet context is ready to accept requests. >Is there a chance, then,
that a request could begin being served while your contextInitialized
method is being
 >carried out (especially if it's long-running)?

>Is contextInitialized suitable only for things like logging the fact
that a context is ready, or can it be used for >setup that MUST occur
before the first request is accepted? If not the latter, what can be
used to serve this 
>function?

ContextInitialized can be used for setting up various services in the
backend before accepting the first request.

--lakshmi

---------------------------------------------------------------------
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: ServletContextListener

Posted by Pid <p...@pidster.com>.
lightbulb432 wrote:
> Can requests potentially arrive at a servlet before the
> ServletContextListener's contextInitialized method has completed? I ask
> because the method occurs as a notification once the servlet context is
> ready to accept requests. Is there a chance, then, that a request could
> begin being served while your contextInitialized method is being carried out
> (especially if it's long-running)?
> 
> Is contextInitialized suitable only for things like logging the fact that a
> context is ready, or can it be used for setup that MUST occur before the
> first request is accepted? If not the latter, what can be used to serve this
> function?

The spec says:

"All ServletContextListeners are notified of context initialization 
before any filter or servlet in the web application is initialized. "

Depends on what they do to know if they complete before servlets are 
started.


p