tags:

views:

133

answers:

2

I need to do for each loop and include loops content to other jsp page. Now I need to pass looped variable to other JSP page. I have tried following, but it didn't work. When I used attribute in included page, it just returned null value.

<c:forEach var="item" items="${items}" varStatus="loop">    
    <jsp:include page="/my_jsp_page.jsp" flush="true">
        <jsp:param name="item" value="${item}" />
    </jsp:include>
</c:forEach>
+1  A: 

You can store the "item" into request attribute before call jsp:include

<c:set var="item" scope="request" value="${item}">

then read it from the request scope

Boris
+1  A: 

This is because jsp:param sets a request parameter, not a request attribute.

From within your included page, you'll have to refer to item like this:

${param['item']}

Note that, since we're talking about request parameters here, those parameters will always be strings. If this doesn't do it for you, you should follow @Boris' advice above.

Isaac