wood burning stoves 2.0*
The moose likes Servlets and the fly likes tomcat question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "tomcat question" Watch "tomcat question" New topic
Author

tomcat question

Chris Huisman
Greenhorn

Joined: Feb 12, 2001
Posts: 21
How do you run a program when tomcat starts up? When tomcat starts up I need to start up a program which does some initializing, and starts a thread when tomcat starts. I would also like to shut this program down when tomcat shutdowns.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

If you are on a dos machine, create two .bat files, one for starting and one for stopping.


SCJP
Visit my download page
Chris Huisman
Greenhorn

Joined: Feb 12, 2001
Posts: 21
So within tomcat how do I get those two .bat to run on startup?
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340
    
    2

I use a .bat program(tom.bat) to start tomcat. I put it in the Windows folder. When I go to MS-DOS Prompt from the start menu, it opens a dos window with the directory set to C:\Windows.
I just type in tom. Here is my .bat program:

You would want to also include code to start your other program.
Im not as sure about stopping.
I stop tomcat from the dos window that is already open.
Sorry I know just enough DOS to get by.
Hope that helps
[This message has been edited by Randall Twede (edited February 12, 2001).]
Ajan Balakrishnan
Ranch Hand

Joined: Jan 04, 2001
Posts: 71
Edit the startup.bat file under jakarta-tomcat-1.3.2\bin directory call your bat file at the :start function
For example change your startup.bat by adding the second line as below
:start
call "%TOMCAT_HOME%\bin\tomcat" start %1 %2 %3 %4 %5 %6 %7 %8 %9
call "c:\yourbatfile.bat"
Hope this helps
Ajan

[This message has been edited by Ajan Balakrishnan (edited February 12, 2001).]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: tomcat question