You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Martin Grogan <mg...@keizensoftware.com> on 2006/05/11 13:24:43 UTC

When is init() called?

Hi all,
I'm new to the list. I was trying to find out exactly when Tomcat will 
call a servlets init() method.
Is it
    a) When tomcat is restarted or
    b) When I restart my web-app context from the Tomcat manager panel.
I ask because we run web-apps on a shared hosting server and don't have 
control over when Tomcat gets restarted, but would need to re-init() our 
servlets from time to time. We are running on Tomcat 5.5.7
Thanks,
Martin

------------
Martin Grogan
Keizen Software

mgrogan@keizensoftware.com
www.keizensoftware.com


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


RE: When is init() called?

Posted by Tim Lucia <ti...@yahoo.com>.
init() is called when the servlet is instantiated.  If you have
<load-on-startup>1</load-on-startup> then it will get called when the web
app is (re)started.  Otherwise, it will get called when the first request
for it is made.  To answer you're a) or b) question, it is both a and b.

Tim


-----Original Message-----
From: Martin Grogan [mailto:mgrogan@keizensoftware.com] 
Sent: Thursday, May 11, 2006 7:25 AM
To: Tomcat Users List
Subject: When is init() called?

Hi all,
I'm new to the list. I was trying to find out exactly when Tomcat will call
a servlets init() method.
Is it
    a) When tomcat is restarted or
    b) When I restart my web-app context from the Tomcat manager panel.
I ask because we run web-apps on a shared hosting server and don't have
control over when Tomcat gets restarted, but would need to re-init() our
servlets from time to time. We are running on Tomcat 5.5.7 Thanks, Martin

------------
Martin Grogan
Keizen Software

mgrogan@keizensoftware.com
www.keizensoftware.com


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



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