This week's book giveaway is in the JavaScript forum.
We're giving away four copies of JavaScript Promises Essentials and have Rami Sarieddine on-line!
See this thread for details.
The moose likes Servlets and the fly likes run servlet after tomcat has started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "run servlet after tomcat has started" Watch "run servlet after tomcat has started" New topic
Author

run servlet after tomcat has started

Isaac Jones
Greenhorn

Joined: Jun 18, 2004
Posts: 25
hi

i have a server servlet which i have to start as follows:

http://localhost:8080/Messenger/com.gekko.messenger.servlet.Server

is there a way to run the servlet right after tomcat has started. i've tried to configure the web.xml file with load on startup but then tomcat doesn't finish starting because i have a while loop in my init method to accept connections.
anyone got an idea how to do this?

thanks, sgl
Nitin Dubey
Ranch Hand

Joined: Oct 30, 2000
Posts: 126

Spwan a thread in the servlet loaded at tomcat startup. This won't stop execution of tomcat server.

Nitin Dubey
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
BAD. Your servlet would lock up Tomcat in that while loop forever from the moment you started it.
At the very least make it thread-safe and have it yield regularly, that should solve your lock problems.


42
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: run servlet after tomcat has started