You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2016/06/06 20:52:17 UTC

[Bug 59668] New: x:forEach retains the incorrect scope when used in a tag called from another x:forEach

https://bz.apache.org/bugzilla/show_bug.cgi?id=59668

            Bug ID: 59668
           Summary: x:forEach retains the incorrect scope when used in a
                    tag called from another x:forEach
           Product: Taglibs
           Version: unspecified
          Hardware: PC
                OS: Mac OS X 10.1
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XTags Taglib
          Assignee: dev@tomcat.apache.org
          Reporter: matthewcasperson@gmail.com

This is related to https://github.com/mcasperson/wildfly_jstl_bug/

There is a bug that occurs when you have a x:forEach in a JSP page, and inside
this x:forEach you call a tag that itself has a x:forEach. The variable created
by the second x:forEach is inaccessible to any nested x:out elements.

This happens because the x:out pagecontext is assigned from the parent
x:forEach (from the tag file), which in turn has its pageContext assigned from
its parent x:forEach (from the JSP page). This means the x:out element has no
access to page scoped variables from the tag.

This bug is known to affect WildFly 10.0.0, which uses code forked from the
Apache TagLib project. See
https://github.com/mcasperson/wildfly_jstl_bug/blob/master/src/main/webapp/index.jsp
and
https://github.com/mcasperson/wildfly_jstl_bug/blob/master/src/main/webapp/WEB-INF/tags/my.tag
for more details. When run, this JSP page produces the exception:

Caused by: javax.xml.transform.TransformerException: Could not resolve XPath
variable: $childNode
            at
org.apache.taglibs.standard.tag.common.xml.JSTLVariableStack.getVariableOrParam(JSTLVariableStack.java:93)
            at org.apache.xpath.operations.Variable.execute(Variable.java:219)
            at org.apache.xpath.operations.Variable.execute(Variable.java:188)
            at
org.apache.xpath.axes.FilterExprIteratorSimple.executeFilterExpr(FilterExprIteratorSimple.java:116)
            at
org.apache.xpath.axes.FilterExprWalker.setRoot(FilterExprWalker.java:131)
            at
org.apache.xpath.axes.WalkingIterator.setRoot(WalkingIterator.java:157)
            at
org.apache.xpath.axes.NodeSequence.setRoot(NodeSequence.java:265)
            at
org.apache.xpath.axes.LocPathIterator.execute(LocPathIterator.java:212)
            at org.apache.xpath.XPath.execute(XPath.java:337)
            ... 41 more

We have a fix which you can view at
https://github.com/jboss/jboss-jstl-api_spec/pull/12/files/e0b0140c879c43c8dc2cc881e5cd3d857935d685..b03bea7ad4d3a92a16d8a9f67434cf033f72ca09.
It is a nasty hack so I am not suggesting this is how the problem should be
solved, but it does demonstrate how pageContexts are being incorrectly assigned
with the x:forEach element and nested tags.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org