aspose file tools*
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
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: 41874
    
  63
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: loading a servlet on tomcat 5.5.1 startup