File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Debugging a servlet program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Debugging a servlet program" Watch "Debugging a servlet program" New topic

Debugging a servlet program

anirudh takkallapally

Joined: Sep 04, 2003
Posts: 14
I have a servlet invoked from an applet , i am trying to debug this servlet program , the communication between the applet and servlet is fine , in the servlet i am trying to create a file ..., which it is not doing ,
basically i would like to know how to view the exceptions that are thrown by the system , i am able to view these exceptions on a tomcat terminal window which comes when i start the server on my standalone windows machine , but there is no terminal window comming on unix machine where i am trying to run the program ,
is there a way to view the exceptions that are generated by the system and how do i view them???
please help
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Use try/catch blocks in your servlet code and return the error description to the client browser. The exceptions are going to the server because you are not catching them.

Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Michael Bronshteyn
Ranch Hand

Joined: Mar 26, 2002
Posts: 85
To debug servlet you need remote debugging capability. You can use jdb or get some java debuggers which will allow you to do so. Then you need to start your servlet container in the debug mode and attach your debugger to the servlet container. After that you can set breakpoint in your servlet code and debug as normal.

Brian Pipa
Ranch Hand

Joined: Sep 29, 2003
Posts: 299
You can use one of the many logging APIs and have it write to a file. You can then view the file to see what's happening. You can even setup a JSP or servlet so that you can view that file remotely froim a browser

My Java Freeware:<br />MACCC - <a href="" target="_blank" rel="nofollow"></a><br />Nator - <a href="" target="_blank" rel="nofollow"></a>
I agree. Here's the link:
subject: Debugging a servlet program
It's not a secret anymore!