File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Reload Servlet-container  from the code? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic

Reload Servlet-container from the code?

Pourang Emami
Ranch Hand

Joined: Sep 21, 2002
Posts: 127
container:either tomcat or oc4j
technology: servlet
OS: winxp pro
How I can Reload tomcat from the code?
I wanted to use Runtime.exec("Tomcat/bin/shutdown") and thenstartup.
But it is so obvious after shutting down there is no possibility to run the second line of code.
Possible sollutions:
1-A restart exe file in the container?
2-Any technique to do this with java?
Thank you for your help.
Best Regards,
Pourang Emami

Best Regards,<br />Pourang Emami
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

It's a bit of a crazy request, but sure, you could probably write a stop-start batch file and run it from the initial Tomcat instance.
I'm reasonably sure it'll be OK, but you need to check that Runtime.exec() retains the OS shell after the parent process dies, otherwise the batch file will die and your restart will still fail.
Just promise me you'll protect this code from the outside world. Just imagine what would happen if it was embedded in a web page and someone used it malicioously
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13037
See my response in the Servlets forum - Ya know, its really annoying when people post the same request in multiple forums.
(Moose bites can be very painful!)
[ October 05, 2003: Message edited by: William Brogden ]
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Closing this. Please refer here for replies.

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
I agree. Here's the link:
subject: Reload Servlet-container from the code?
It's not a secret anymore!