File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes init and destroy. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "init and destroy." Watch "init and destroy." New topic

init and destroy.

Chhaya Dhanani
Ranch Hand

Joined: Apr 11, 2001
Posts: 70
Why are the System.out.println()(SOPs) statements not printed on my console when they are included in the init and destroy methods.?
If i write SOPs in my doGet and doPost , they get printed.?
Also , i would like toknow whether a servlet and can have acinstructor written? what would be the impact of this contructor on the servlet life cycle?
Thanx in advance,
Kunaal A Trehan
Ranch Hand

Joined: Feb 04, 2004
Posts: 63
You can have a constructor for servlet.There wud be no impact.The constructor wud be called once just like init() when servlet is loaded
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12871
System.out.println should print from your init and destroy methods - if not you may have a serious problem. The first thing I would suspect is that the method signatures are not correct. You better double-check by looking at the javax.servlet.GenericServlet JavaDocs.
Gareth Western
Ranch Hand

Joined: Apr 07, 2004
Posts: 45
Silly question, but are they not being printed to your container log?
i.e. If using Tomcat then look in $TOMCAT_HOME/logs/catalina.out
subject: init and destroy.