This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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:
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 ?
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.