11

I've set a breakpoint in a JSP when running a Tomcat application through IntelliJ IDEA (Ultimate ed.). So far so good, I can step through the JSP as expected.

The problem is: I am unable to resolve Spring model variables such as ${path} when debugging. Evaluate Expression triggers an error: "Cannot find variable 'path'".

As a workaround I can explicitly reference the model value with <c:set var="testPath" value="${path}">. That way I can see testPath in Variables » _jspx_page_context » attributes, but not path.

neu242
  • 15,796
  • 20
  • 79
  • 114
  • 1
    Please add code as well. – Krutik Jayswal Jun 18 '15 at 10:49
  • Maybe you wanna have a look at this: http://stackoverflow.com/questions/14878548/intellij-idea-resolving-web-paths-in-jsp – Aditya Singh Jun 21 '15 at 18:38
  • Try these 1. [http://stackoverflow.com/questions/33739/jsp-debugging-in-intellij-idea][1] 2. [http://stackoverflow.com/questions/12694392/intellij-not-resolving-el-variables-within-jsp-code-inspection-or-autocomplete][2] [1]: http://stackoverflow.com/questions/33739/jsp-debugging-in-intellij-idea [2]: http://stackoverflow.com/questions/12694392/intellij-not-resolving-el-variables-within-jsp-code-inspection-or-autocomplete – Saidolim Jun 21 '15 at 20:29
  • AdityaSingh & @Saidolim: None of those are relevant to my question, since I'm actually able to debug the JSP. – neu242 Dec 17 '15 at 11:11

2 Answers2

11

Variable path is part of the Spring Framework and is set as an attribute to the PageContext, there are only few ways of debbugging such variables.

For me the best solution is to add an expression to your Watches View: pageContext.findAttribute("path") or _jspx_page_context.findAttribute("path")

It doesn't matter, because both of them point to the same runtime object:

enter image description here

aw-think
  • 4,723
  • 2
  • 21
  • 42
  • 1
    Thanks! `pageContext` isn't available in my Variables view, but `_jspx_page_context` works fine. – neu242 Jun 26 '15 at 13:52
  • @neu242 Ah ok, don't know that. Thought an pageContext is visible to all. Thank you for your response. – aw-think Jun 26 '15 at 13:53
  • Nice answer! I had a similar need but using Eclipse rather than IntelliJ. This answer helped although it seems in Eclipse it seems even harder to get to the info (but fortunately still possible): Need to go to the Variables view and then expand `_jspx_page_context - pageAttributes - table` and then open each mapped index individually and inspect the key/value for each. – Steve Chambers Oct 18 '16 at 08:42
1

This is only a work-around, and is certainly not best practices. However, if you need something quick and dirty, set another String var to your $path param. The debugger will be able to see that new variable at runtime.

Japes
  • 255
  • 2
  • 16