jQuery in Action, 3rd edition
The moose likes Servlets and the fly likes How to debug in servlet in Tomcat? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to debug in servlet in Tomcat?" Watch "How to debug in servlet in Tomcat?" New topic

How to debug in servlet in Tomcat?

John McDonald
Ranch Hand

Joined: Jul 01, 2003
Posts: 112
Hi there,.
I have a null pointer exception so often from the servlet that I invoked. How do I debug it? Thanks.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13036
Logging the full stack trace would be a good start.

The most common causes of NPEs in servlets are:
1. not checking request parameters for null before trying to use them
2. not checking init parameters for null - ditto

Bruno Boehr

Joined: Feb 15, 2006
Posts: 17
Depending on what IDE you are using you might be able to do debugging directly in the source code. I use Eclipse with a Tomcat plugin by Sysdeo (http://www.sysdeo.com/eclipse/tomcatplugin), and it works just great for me.

<a href="http://webjavenue.com/" target="_blank" rel="nofollow">Your first website in Java: easier than you think</a>
Pavan Tammana

Joined: Mar 08, 2006
Posts: 6
Hey John,
Use Log4j which is provided by Apache. It is a good tool for logging. If you don't want logging at all, i would say you can do remote debugging. All most all the IDE's have a remote debugging feature. That's what you do for a production support project.

Pavan Kumar Tammana.
I agree. Here's the link: http://aspose.com/file-tools
subject: How to debug in servlet in Tomcat?
It's not a secret anymore!