aspose file tools*
The moose likes Servlets and the fly likes Right way to diagnose problems in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Right way to diagnose problems in a servlet" Watch "Right way to diagnose problems in a servlet" New topic
Author

Right way to diagnose problems in a servlet

Pres Brawner
Ranch Hand

Joined: Jan 18, 2001
Posts: 92
Very basic question.
I'm attempting to diagnose what is happening in a servlet. My usual way would be to put in an IDE and walkthrough the code debugger. Not an option this time.
The other course of action that I take is just to put System.out.println("whatever") to indicate location and status of some variables.
Where does that print in the case of a servlet? I'm using Orion and I'm not seeing the servlet container produce the diagnostic message, which is what I expected.
Thanks!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
Servlet containers typically redirect System.out and System.err to log files - surely it is in the documentation somewhere.
You can get the full text of the debugging chapter from my servlet/JSP book at:
http://www.lanw.com/books/servletjsp/default.htm
Basic rules: Never throw away the information in an exception, make helper classes that can be debugged offline.

------------------
author of:


Java Resources at www.wbrogden.com
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15657
    
  15

Many IDEs CAN debug servlets, including WebGain's Visual Cafe and Sun's Forte (which actually starts up a copy of Tomcat). I'd be very suprised if IBM's Visual Age isn't included, and I'm also pretty sure Borland's IDE does so too.
However, println works too - I've used it with Tomcat and WebLogic. I'm reasonably certain that if you dig, you'll find that Orion has some special place where stdout and stderr println's go too.
You can also use the servlet log() method - which is really what you ought to be using for any production code so it shows up in whatever official logging facilities you're using.


Customer surveys are for companies who didn't pay proper attention to begin with.
Juan Zhang
Greenhorn

Joined: Apr 19, 2001
Posts: 13
I use JOptionPane.showMessageDialog(null,"check variable") to diagnose what is happening in servlet and JSP. It works for me, but I don't know if it is the right way.
Juan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Right way to diagnose problems in a servlet
 
Similar Threads
"Failed to Install the MIDlet"
reading big file using java nio
why we need to use servlet context listener ?
Orphan delete doesn't seem to be working properly
Need help on Passing parameters