This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes HttpSessionListener : Where can i see this output ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "HttpSessionListener : Where can i see this output ?" Watch "HttpSessionListener : Where can i see this output ?" New topic
Author

HttpSessionListener : Where can i see this output ?

Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

I saw some println() statements below. They wont be in the response. So where can i see them ?
Also, how do i see the number of total-active-sessions ? how do i display it in my response ?

The code:



here is the link where i got it : http://www.mkyong.com/servlet/a-simple-httpsessionlistener-example-active-sessions-counter/

SCJP 6. Learning more now.
rinku jain
Greenhorn

Joined: Jan 04, 2011
Posts: 26
use out.println("");

instead of system.out.println();//this out put will be shown on server console
Ravishanker kumar
Ranch Hand

Joined: Jul 20, 2006
Posts: 53
Those would be appear on server console.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Ravishanker kumar wrote:Those would be appear on server console.


How to see the server console ? (i am using tomcat 6)
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Actually, println isn't something we encourage. There's no telling where it can end up, since it's up to the server to decide. It's better to use one of the loggers such as log4j or java.util.logging interface (a/k/a "JULI").

The console for Tomcat is usually the logs/catalina.out file. Except when it isn't. The catalina.out file is normally directed there, but in a few specialized Tomcat configurations, it may be directed somewhere else. It's actually just the JVM's stdout/stderr.


Customer surveys are for companies who didn't pay proper attention to begin with.
Rahul Sudip Bose
Ranch Hand

Joined: Jan 21, 2011
Posts: 637

Tim Holloway wrote:
It's better to use one of the loggers such as log4j or java.util.logging interface (a/k/a "JULI").


I am new and i was wondering if log4J can take more than a day to learn for basic purposes ? java.util.logging - any suggestions for how i can learn to use this (links/books perhaps) ?
Can newbies skip logging initially ?

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

Rahul Sudip Bose wrote:
Can newbies skip logging initially ?


Hey, how else can we tell you're newbies?

Log4j is pretty easy to use. You just plop down a jar in the classpath and create a log4.properties or log4j.xml file in the classpath root that defines what logfile(s) you're using - assuming you log to files - and what log IDs (usually that's the package name of the class where the log statement is).

JULI is even easier, since it's built right into the JRE and the config file is in the JRE lib directory.

Actual use is trivial. You have several different logging levels, running from DEBUG/FINEST to ERROR. A logger can be configured to report only messages at or above a selected level.

Log statements are as simple as replacing "System.out.println()" with "log.info()", although you do need a definition for "log" in your class. I have an IDE hotkey set up for that since I do it so often.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: HttpSessionListener : Where can i see this output ?
 
Similar Threads
When the jsp contacts the servlet for the first time in a session
Synchronizing Session Counter
return a specific session attribute from HttpSessionListener
global session counter
Updating a JSP session attribute and html code on mouse click