Hi ! When i try to override init() method in my servlet and wanted to print some String in the console using System.out.println("Some String");.. I didn't see the output in console. Pls enlighten me on this one. Thanks!
I remember someone else besides me mentioning this before. I think Tomcat has that problem with version 4 or 4.1 on Windows. Try writing to a file to check whether servlet is actually initialized. Thanks
I also found that problem with the init(). I am using version 4.1.18. I finally used getServletContext() and the log() to write whatever I needed in the log. A bit of a pain to have to shut down Tomcat to look at the log but it told me what I needed to know at the time.
Better way would be use Log4j to log to a file that way you need not shut down server everytime. Later you can reconfigure Lo4j to print to console Thanks
Another thing.. Is there a method(or a way) to know how many active sessions(HttpSession) are there inside a servlet container?.. inside a web application? Thanks in advance
You can have a class that implements HttpSessionListener interface. Then you can increase the count when a new session is created in the sessionCreadted method and decrease the count in sessionDestroyed method. If you have Manning book, Refer Pg no:121. Good Luck!
Thanks! Yes, I have that book.. but i think that applies only for a certain web application.. How about tracking all active sessions inside a servlet container serving many web applications simultaneously? Thanks again