Startup class in Tomcat 5.x
Folks, Is there a way in which we can write a startup class in Tomcat. Similar to what we have in Weblogic? I am aware of the approach of writing a servlet and setting load-on-startup to 1. But wanted to confirm if this is really the only way out. Cheers, Prabhu S This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful. Visit us at http://www.cognizant.com
Re: Startup class in Tomcat 5.x
The servlet spec is your friend: http://www.jcp.org/en/jsr/detail?id=154 Among other things, SRV.10 of the spec describes the use of event listeners like javax.servlet.ServletContextListener for handling events like when a webapp starts or stops. Completely portable to all servlet 2.4 spec compliant containers. --David Sethuraman, Prabhu (Cognizant) wrote: Folks, Is there a way in which we can write a startup class in Tomcat. Similar to what we have in Weblogic? I am aware of the approach of writing a servlet and setting load-on-startup to 1. But wanted to confirm if this is really the only way out. Cheers, Prabhu S This e-mail and any files transmitted with it are for the sole use of the intended recipient(s) and may contain confidential and privileged information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. Any unauthorized review, use, disclosure, dissemination, forwarding, printing or copying of this email or any action taken in reliance on this e-mail is strictly prohibited and may be unlawful. Visit us at http://www.cognizant.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
startup class in Tomcat
Besides setting load-on-startup in the web.xml file, is there another way to have a startup class define in Tomcat? ( ie I want a class to run whenever Tomcat is started) Bill - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: startup class in Tomcat
Make a servlet which init() only calls the methods needed in your class. That way you extract the functionality to your class and the servlet is only a wrapper. In other words, create a new servlet that actually does nothing except in the init method it calls the necessary methods in your class. Regards Stefan -Original Message- From: William Au [mailto:[EMAIL PROTECTED]] Sent: 23. janar 2001 15:43 To: [EMAIL PROTECTED] Subject: Re: startup class in Tomcat The way I understand it, load-on-startup will only work on a servlet, and only the init() method is called. What I have now is a generic Java class. So I will have to convert it into a servlet and put most of the code inside init(). I was just trying to see if I can use my class as-is. Bill Michael Wentzel wrote: Besides setting load-on-startup in the web.xml file, is there another way to have a startup class define in Tomcat? ( ie I want a class to run whenever Tomcat is started) Sounds to me like load-on-startup is what you need... Is there some reason this does not fit your needs? --- Michael Wentzel Software Developer A HREF="http://www.aswethink.com"Software As We Think/A A HREF="mailto:[EMAIL PROTECTED]"Michael Wentzel/A - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: startup class in Tomcat
William Au wrote: Besides setting load-on-startup in the web.xml file, is there another way to have a startup class define in Tomcat? ( ie I want a class to run whenever Tomcat is started) Tomcat 4.0 implements the new "application events" feature of the Servlet 2.3 (Proposed Final Draft) spec. Among the events you can register listeners for are application startup and shutdown -- perfect places to do things like opening and closing database connections, independent of the lifecycle of an individual servlet. Bill Craig McClanahan - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]