user3120173 user3120173 - 7 months ago 46
Java Question

Debugging inside a JSP page?

I'm using Java 1.6, Spring 3.4, Spring Webflow 2.3.2 and Tomcat 7. I'm trying to debug a JSP page which uses EL expressions like:

<c:if test="${myObject.myThing == SomeClass.ENUMVALUE.myvalue}" >

object is passed in as the Webflow model object. I have a breakpoint set on this line and I am able to reach it and break on it, but anything I try to "watch" or "evaluate" gives me an error message. I get either

${myObject.myThing == SomeClass.ENUMVALUE.myvalue}: Invalid Expression

myObject.myThing: Type is unknown for 'myObject'

(MyCorrectType) myObject: Cannot find local variable 'myObject'

How the heck can I find this model object? What is it contained in by the time it reaches the JSP page?


The answer turned out to be that it will be in the org.apache.catalina.connector.Request object (In my particular case, it was buried several levels deep inside wrapper objects.)

If you are using a debugger, like the one in Intellij (which I use), you can get the value of an individual attribute (like the Webflow model object) by evaluating the expression request.getAttribute("attributeName"). Note that this may return a Java Object type, and you may have to cast it to the correct type.

For example, in my case, I was able to find the value of the value I wanted using this expression:


I hope this helps somebody.