tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Frank W. Zammetti" <>
Subject Re: execute class on start up
Date Mon, 22 Aug 2005 11:34:10 GMT
You can do it a couple of ways...

(1) You could create a startup servlet and load it on startup to call 
your class.

(2) You could use a ContextListener to do the same thing.

Both of those require a webapp of course, and it's not obvious that you 
actually want there to be one.  So, you could also:

(3) Use a static initializer block in the class.  This may not be 
feasible depending on what you need to happen at startup, but it would 
"execute" the class every time Tomcat starts up, as long as its in the 
classpath, whether its part of a webapp or not.


Xavier López wrote:
> Hello,
> I have a little problem, and perhaps you can help me!
> I made a new java class and I just want to execute it every time 
> that the server Tomcat starts.
> Does anyone know how to do it ?
> I think thats a configuration problem, but I don't know how to solve it.
> Thanks in advance!
> Xavier
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies

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

View raw message