Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Debug a servlet

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo,

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

regards
M
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Run your server in debug mode and set a breakpoint.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 127
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just start tomcat from within Eclipse, set a breapoint and it works.
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need the Tomcat plugin for Eclipse...
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The System.out was the best easy way I found out to debug my servlet...
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Michael

Which Tomcat plugin you mean ?

Regards,
M
 
Michael Ku
Ranch Hand
Posts: 510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need the Tomcat plugin for Eclipse...


I do not know how to be more specific than this
 
Marcus Green
arch rival
Rancher
Posts: 2813
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic