Mantis - Resin
Viewing Issue Advanced Details
707 minor always 01-05-06 13:04 01-24-06 16:34
bregnvig  
ferg  
normal  
closed 3.0.17  
fixed  
none    
none 3.0.18  
0000707: c:forEach uses the requestScope for var attribute
I have a JSP that uses several c:import tag.

In my action (I'm using Struts) I have the follwing line:

request.setAttribute("cmsPage", cmsPage);

In my imported "menu" page, which is imported before my content page, I have the following code (In this case it is not relevant where the "cmsPages" attribute comes from):

<c:forEach var="cmsPage" items="${cmsPages}">
   ${cmsPage.menu}
</c:forEach>

In my later imported content page I have something like this:
<div>
    ${cmsPage.content}
</div>

The problem is that the "cmsPage" attribute in the menu page has now overridden my "cmsPage" attribute in the content page, leaving it as null or empty.

My point is that the var attribute in the c:forEach tag, in this case "cmsPage" should have been stored in the pageScope. Not on the requestScope. The spec says the following about the var attribute: "This scoped variable has nested visibility." Not the case here.

Notes
(0000774)
ferg   
01-24-06 16:34   
jsp/1cm8, jsp/1dm8