This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

load-on-startup

 
Sachin Deshpande
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • 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
 
nirmal baba
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes the system.out.printlns were there in the service method
putting them in init worked
thanx
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic