• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

run servlet after tomcat has started

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 126
Oracle
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Spwan a thread in the servlet loaded at tomcat startup. This won't stop execution of tomcat server.

Nitin Dubey
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
reply
    Bookmark Topic Watch Topic
  • New Topic