aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Debug a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Debug a servlet" Watch "Debug a servlet" New topic
Author

Debug a servlet

Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hallo,

How I can debug a Servlet using the. eclipse ?
Thanks

regards
M


SCJP, SCJD, SCWCD, OCPJBCD
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
Run your server in debug mode and set a breakpoint.
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi, Michael

Thanks for your answer, but can you provide more details ?
How to start the tom cat server in the debug mode ?

What I don't understand is even if the tom cat runs in the debug mode my servlet runs in the tom cat's container so I need to start the tom cat under eclipse in the debug mode. Is this statement correct or I miss something ?


Regards,
M
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42950
    
  71
I'm not sure about Eclipse' capabilities, but even if the server doesn't run within an IDE, you can use an external debugger like JSwat to debug it.
Vilas Lawande
Ranch Hand

Joined: Nov 07, 2006
Posts: 127
you can use object of PrintWriter i.e. out
& write
out.println("A");
out.println("B");
out.println("C");

for point where you want to debug the servlet.
So that we got exact point of error in servlet.
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Guys, thanks for the answer.

Ulf, what you suggest is nothing more than a java debuger, my question is (was) how I get the container to run in to a debuger ?


Vilas, this system.out kind of debug I want to avoid, I'll like a real debuger (with breakpoints, stack tray, etc)

Regards
M
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
I just start tomcat from within Eclipse, set a breapoint and it works.
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
You may need the Tomcat plugin for Eclipse...
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9629
    
    2

The System.out was the best easy way I found out to debug my servlet...


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Hi Michael

Which Tomcat plugin you mean ?

Regards,
M
Michael Ku
Ranch Hand

Joined: Apr 20, 2002
Posts: 510
You may need the Tomcat plugin for Eclipse...


I do not know how to be more specific than this
Marcus Green
arch rival
Rancher

Joined: Sep 14, 1999
Posts: 2813
I have always found NetBeans to be far easier and more intuitive thn Eclipse for developing and debugging. It is a single download with the tomcat as part of the installation and once you start in debug mode it feels very intuitive.

You create a project as a web application.

http://www.netbeans.org


SCWCD: Online Course, 50,000+ words and 200+ questions
http://www.examulator.com/moodle/course/view.php?id=5&topic=all
Mihai Radulescu
Ranch Hand

Joined: Sep 18, 2003
Posts: 918

Thanks, I just try it with net beans and it works. Now I'll try some eclipse plugins.

Regards,
M
[ October 04, 2007: Message edited by: Mihai Radulescu ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Debug a servlet