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 The Software Craftsman this week in the Agile 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

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.
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12912
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:
Basic rules: Never throw away the information in an exception, make helper classes that can be debugged offline.

author of:
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16540

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

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.
subject: Right way to diagnose problems in a servlet