• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Debugging servlets

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Does anyone know how to debug a servlet using Eclipse & Tomcat?
I've created a servlet.
Started Tomcat via Eclipse.
Ran my servlet via a Browser.
...
But, I don't know how or can't debug the servlet.
Can anyone help?
Or maybe there is a better way to debug servlets
Thanks in advance.
Danny.
:roll:
 
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I use Log4j and write log at interested points, view the log file as it gets updated in real time.
Need to find a better way if there is any.
Thanks,
Bhushan
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The debugging chapter from my Servlets and JSP book is available at:my page for the book.
There is also a downloadable utility that you can use to spy on the exact text of request and response.
Bill
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The best way to debug servlets that I have found is to make it so there is as little code as possible in the servlet itself, and as little code as possible which depends on "non-mockable" Servlet API classes.
I typically have just enough code in the servlet to extract the parameters from the Request and the Writer from the Response, and pass them in to a more testable class for the "heavy lifting".
Once you have this, you can put a simple "main" wrapper round your code (or, even better, a JUnit wapper), and debug and test it under full control on your own desktop, using your favourite tools with no deployment necessary.
Have you tried this ?
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can debug it remotelly.
you can setup tomcat.sh to start as debug server and use debugger to connect. if you use bugseeker ( http://www.karmira.com ) it is very easy to setup a project for remote debugging.
you can even debug jsp pages generated servlets, with a little extra work.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ummm... what Tomcat plugin are you using? It SHOULD be as easy as setting a breakpoint in your Servlet and starting Tomcat in Debug mode...
Kyle
 
Danny Duong
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm actually using eclipse as the IDE.
I'm not too sure how to turn on Tomcat for debug.
It is probaly a simple setting - but I don't know how?
If you know how, can you let me know.
Thanks.
 
reply
    Bookmark Topic Watch Topic
  • New Topic