tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael E. Locasto" <locas...@TCNJ.EDU>
Subject re: Howto autorun an application when tomcat server startup?
Date Tue, 30 Apr 2002 14:36:10 GMT


I am not sure how you would go about doing this in Tomcat 4, but in
in the $TOMCAT_HOME/webapps/yourwebapp/WEB-INF/web.xml file, you could
write a special XML tag and give the fully qualified classname of your
Java class (e.g. com.yourcompany.MyApplication) in those tags. When
starts, it will read all the web.xml files, and finding this tag
your class, it will load that class. I've used this to make a static
Connection Pool available to all web applications running in Tomcat.

you should probably make your class ( extend Servlet.
Since Servlet has an init() method that will be called once, your
will be started by Tomcat, so you don't have to start it manually. Do
your work in init() rather than doGet() or doPost(), so people just
don't call
your servlet and make it do work all over again.

see $TOMCAT_HOME/webapps/text/WEB-INF/web.xml for more details
see $TOMCAT_HOME/conf/web.xml for more details

make sure your class (MyApplication.class) is in Tomcat's classpath

use this tag: <load-on-startup></load-on-startup>


I'm not sure what the numbers mean :), but it has seemed to work for me.

I'm not sure this procedure is still valid in Tomcat 4 or if I've gotten
things mixed up in the explanation above, but it should be a start for

Michael Locasto

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message