This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes loading a servlet on tomcat 5.5.1 startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "loading a servlet on tomcat 5.5.1 startup" Watch "loading a servlet on tomcat 5.5.1 startup" New topic
Author

loading a servlet on tomcat 5.5.1 startup

amit sanghai
Ranch Hand

Joined: Dec 05, 2000
Posts: 231
Hi,

I have Tomcat 5.5.1. I want to run a servlet when the server starts. How do I do that?

I tried using <load-on-startup>1</load-on-startup> but it did not work.

Please help.

Thanks and regards,
Amit Sanghai.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41068
    
  43
Having a load-on-startup element inside of the servlet element should do the trick. Note that it will run the init method, not any of the other methods.

Using Tomcat 5.5 you should really use the contextInitialized method of a ServletContextListener, though. load-on-startup is a hack, and has been made obsolete by context listeners.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: loading a servlet on tomcat 5.5.1 startup
 
Similar Threads
cannot load servlet name :
How can I verify the ocurrence of <load-on-startup> Servlet? (TOMCAT)
Web application
Deploy struts app
Running a servlet on startup