File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
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: 13027
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 (, and it works just great for me.

<a href="" 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:
subject: How to debug in servlet in Tomcat?
It's not a secret anymore!