wood burning stoves*
The moose likes Servlets and the fly likes load-on-startup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "load-on-startup" Watch "load-on-startup" New topic
Author

load-on-startup

Sachin Deshpande
Greenhorn

Joined: Jan 31, 2001
Posts: 25
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

Joined: Apr 06, 2001
Posts: 10
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

Joined: Jan 31, 2001
Posts: 25
yes the system.out.printlns were there in the service method
putting them in init worked
thanx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: load-on-startup
 
Similar Threads
Why is my servlet loaded twice?
Homepage contains data fetch by database
How can I verify the ocurrence of <load-on-startup> Servlet? (TOMCAT)
Preloading JSP's
load-on-startup