• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to debug in servlet in Tomcat?

 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,.
I have a null pointer exception so often from the servlet that I invoked. How do I debug it? Thanks.

John
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13073
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Bill
 
Bruno Boehr
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pavan Tammana
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks,
Pavan Kumar Tammana.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic