tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Baringer <marco.barin...@convey.it>
Subject Re: how to execute a .class file automatically when tomcat is started
Date Wed, 09 May 2001 12:49:01 GMT
You'll have to create a servlet and you can tell Tomcat to load (run
it's init() method) it on startup. If the class is called mail.Core
(and it must extend javax.servlet.GenericServlet (or one of its sub
classes))

put this in your app's web.xml:

<servlet>
  <servlet-name>this doesn't matter</servlet-name>
  <servlet-class>mail.Core</servlet-class>
  <load-on-startup>0</load-on-startup>
</servlet>

NB: If you have more than one of these tomcat will call them in order
(ascending) based on the value of the load-on-startup tag's body. ok?

NB: this means that the class mail.Core must be on Tomcat's CLASSPATH,
put it in WEB-INF/classes, a jar in WEB-INF/lib or whatever.

I've found that using this along with <init-param> tags is an easy way
to configure my app.

To find out more than you've ever wanted to know about web.xml and
everything you could go read the Java Servlet Specification
(http://java.sun.com/servlet/something-or-another)

-- 
-Marco
Ring the bells that still can ring.
Forget the perfect offering.
There's a crack in everything.
It's how the light gets in.
	-Isonard Cohen

Mime
View raw message