• 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

load-on-startup

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a singleton servlet which i want to load on startup of tomcat server. I have added 'load-on-startup' tag with a random value(23) in web.xml file of the application which contains this servlet. I have some system.out.printlns in this servlet which print out something when the servlet has been loaded(and I can confirm that the servlet has been genuinely loaded. I cant see these System.out.println s! But when the servlet is explicitly called, i can see the system.out.printlns, suggesting that the servlet was not loaded when tomcat started. Am I missing something? How do I see those system.out.printlns at startup
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Loading a servlet involves three things-class loading from deployment archive+instantiation+initialization!!....In ur case even though the servlet is getting instantiated and loaded at startup ,it is not showing the System.out.println statements probably because u have put them in the service()/doGet()/doPost() method of ur servlet!! That's why they r showing up when one of these methods is invoked as a part of request processing.
They will appear at startup time only if u keep them in the init() method...Kindly try and confirm
Good Luck
Nirmal
 
Sachin Deshpande
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes the system.out.printlns were there in the service method
putting them in init worked
thanx
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic