• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

loading a servlet on tomcat 5.5.1 startup

 
amit sanghai
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic