Debugging inside a JSP page?

I am using Java 1.6, Spring 3.4, Spring Webflow 2.3.2 and Tomcat 7. I am trying to debug a JSP page that uses EL expressions, for example:

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

The myObject is passed as an object of the Webflow model. I have a breakpoint set on this line and I can reach and break it, but everything that I try to β€œobserve” 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 can I find this model object? What does it mean when it reaches the JSP page?

0
java spring spring-webflow jsp
source share
2 answers

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 at several levels inside the shell objects).

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

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

 ((MyObject)(request.getAttribute("myObject"))).getMyThing() 

Hope this helps someone.

+1
source share

In IDEA 2016.2 request in JSP debugging no longer works :(

Attribute can be obtained as

 _jspx_page_context.request.getAttribute("...") 

(internal tag as parentTag.requestContext.request.getAttributeNames() )

It is also possible to add a project dependency on jasper with a scope provided:

  <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>jasper</artifactId> <version>6.0.47</version> <scope>provided</scope> </dependency> 

and do auto-complete:

enter image description here

0
source share

All Articles