Index: java/org/apache/jasper/runtime/JspContextWrapper.java =================================================================== --- java/org/apache/jasper/runtime/JspContextWrapper.java (revision 729765) +++ java/org/apache/jasper/runtime/JspContextWrapper.java (working copy) @@ -377,9 +377,9 @@ Object obj = getAttribute(varName); varName = findAlias(varName); if (obj != null) { - invokingJspCtxt.setAttribute(varName, obj); + getOuterInvokingJspCtxt().setAttribute(varName, obj); } else { - invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE); + getOuterInvokingJspCtxt().removeAttribute(varName, PAGE_SCOPE); } } } @@ -394,7 +394,7 @@ while (iter.hasNext()) { String varName = iter.next(); varName = findAlias(varName); - Object obj = invokingJspCtxt.getAttribute(varName); + Object obj = getOuterInvokingJspCtxt().getAttribute(varName); if (obj != null) { originalNestedVars.put(varName, obj); } @@ -413,15 +413,37 @@ varName = findAlias(varName); Object obj = originalNestedVars.get(varName); if (obj != null) { - invokingJspCtxt.setAttribute(varName, obj); + getOuterInvokingJspCtxt().setAttribute(varName, obj); } else { - invokingJspCtxt.removeAttribute(varName, PAGE_SCOPE); + getOuterInvokingJspCtxt().removeAttribute( + varName, PAGE_SCOPE); } } } } - /** + /** + * Obtain the page context for the invoking tag/page. + * + * @return The page context for the invoking tag/page + */ + protected PageContext getInvokingJspCtxt() { + return invokingJspCtxt; + } + + /** + * Obtain the page context for the invoking JSP page. Where iterative tags + * are in use this will eb idfferent to {@link #getInvokingJspCtxt()}. + */ + private PageContext getOuterInvokingJspCtxt() { + PageContext pc = invokingJspCtxt; + while (pc instanceof JspContextWrapper) { + pc = ((JspContextWrapper) pc).getInvokingJspCtxt(); + } + return pc; + } + + /** * Checks to see if the given variable name is used as an alias, and if so, * returns the variable name for which it is used as an alias. *