Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug servlet using Eclipse

Have a servlet and it can run inside TomCat. However, I am not sure how to debug it inside Eclipse(Java Standard version). Any suggestions?

like image 394
user496949 Avatar asked Mar 14 '11 23:03

user496949


People also ask

How do I run debugging in Eclipse?

A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.

Can we debug JSP in Eclipse?

Set a BreakpointWorkshop extends the Eclipse debugger to allow you to debug JSP code. To set a breakpoint: Right-click in the gutter of the Source view and select Toggle Breakpoints.

Which Eclipse is used for servlet?

You need to download the eclipse ide for JavaEE developers. Creating servlet example in eclipse ide, saves a lot of work to be done. It is easy and simple to create a servlet example.

Why my servlet is not working in Eclipse?

Add the server runtime to the web project to fix the HttpServlet not found Eclipse error. This will add all the JAR and ZIP files used by the servlet engine to the web project's runtime path. When this step is complete, rebuild the project and the HttpServlet not found Eclipse error message will go away.


2 Answers

First ensure that you're using "Eclipse IDE for Enterprise Java Developers", with the Enterprise in its name, and thus very definitely not just "Eclipse IDE for Java Developers".

Once ensured/upgraded, put breakpoints in the servlet code the usual way and run the server in debug modus. Rightclick the server in Eclipse and choose Debug instead of Start (or click the bug button instead of the green arrow on the button panel of the servers view). Then fire a HTTP request on the servlet using your favourite webbrowser. Eclipse will open and focus the debug panel when the particular code line with the breakpoint is about to be executed.

like image 98
BalusC Avatar answered Oct 16 '22 11:10

BalusC


Right-click on project -> Debug as -> Debug on server should do the trick

like image 4
ThomasRS Avatar answered Oct 16 '22 12:10

ThomasRS