Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to inspect a variable on a JSP page?

Tags:

java

eclipse

jsp

I have a set of working pages and want to inspect variables at a breakpoint on a JSP page. Unfortunately, the context menu for the variable doesn't show the normal Inspect/Watch options as it does when in a Java file. Any ideas?

like image 358
glez Avatar asked Oct 19 '12 19:10

glez


People also ask

Can we debug in JSP?

From the JSP file's context menu in the Project Explorer view, click Debug As> Debug on Server. The workbench switches to the Debug perspective and the server is launched in debug mode. In the Debug view, step through the code and make the necessary changes to the JSP file.

Where do JSP variables come from?

They appear to be coming from the included file. A JSP page executes in a context where quite a few variables are providedu: the request, the URL, the session, ...

Can we put breakpoint inside JSP?

If you have WTP installed, you can set breakpoints within a JSP and they work fine in a regular "remote debug" session. However, once you've stopped on a breakpoint, stepping through the code is nigh on impossible and finding whatever it is that you wish to inspect takes a lot of digging around in the "Variables" view.


2 Answers

Here is a solution worked for me:

In Eclipse open the Display tab view (Window -> Show View -> Display) In the Display tab write the variable or expression you want to inspect. Select it and do a right click and you'll have the a menu with the option inspect (or you can do a Ctrl + Shift + I), it will show you the value of the variable.

Hope it helps!

like image 91
Martín C Avatar answered Oct 13 '22 00:10

Martín C


Struggled with the same problem and then looked at the variables View(Window) in Eclipse. All variables are there with their names and values.

But watch/inspect entries are indeed missing in right click menu.

BTW, I'm using Eclipse Kepler.

like image 33
mp31415 Avatar answered Oct 13 '22 02:10

mp31415