File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Debugging Servlets -- Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Debugging Servlets -- Help" Watch "Debugging Servlets -- Help" New topic
Author

Debugging Servlets -- Help

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1083
What's the best way to debug a servlet under Tomcat when you don't have access to the STDERR.LOG and STDOUT.LOG files (or catalina.log) files?
The way I normally debug a servlet is to look at the STDOUT.LOG files for the output of my System.out.println() commands. However, since I don't have access to these logs on the commercial web server, this approach won't work.
Is a good way to just write to a text file on the web server (in a directory you do have rights to) using java File classes?
I'm interested to hear any thoughts or ideas to debug a servlet that works fine under localhost, but fails on the actual web server (where I don't ahve access to the logs I need).
Thanks in advance to all!
-- Mike
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
For one suggestion - if you are just serving HTML - make sure every exception in your doGet or doPost is caught and try to return a HTML page with the full stack trace. (Hint - format with < pre >
Bill
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1083
Hi Bill,
Sorry, not so simple. The code that doesn't work on the web server is a class that generates JPEG files....no doGet() or doPut() in scope, unfortunately.
Do you think creating a local file from the JPEG writer class based on what's happening in the JPEG-writer class (for example "You're now about to execute the write" type messages).
Look forward to your reply.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12835
    
    5
I think I would write a log to a StringWriter and make the resulting String accessible to another servlet or possibly to another function in the same servlet. So if your JPG generator serves an image on doGet you could add a doPost that shows the most recent log string. I have occasionally had debugging functions built in to servlets this way - naturally with some sort of password required.
Bill
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1083
Thanks for your reply.
-- Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Debugging Servlets -- Help