Seeing the absence of any answer and the question looking fairly trivial, I don't think there are many Stripes users out here. so here are my two cents:
This is definitely a scoping problem. the <s:layout-component>
doesn't have access to the page/loop scope of the parent page. Similar problem exist in JSP/JSTL when you do a <jsp:include>
inside a <c:forEach>
. The loop variable is inaccessible in the code snippet included by <jsp:include>
. But in JSP/JSTL that could be solved by passing a <jsp:param>
along the <jsp:include>
. I took a quick look in the Stripes documentation and I discovered a <stripes:param>
. See if that helps. At least here's a JSP/JSTL based SSCCE to get the idea:
main.jsp
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
// Just for demo purposes. Do NOT use scriptlets in real work.
request.setAttribute("items", java.util.Arrays.asList("foo", "bar", "waa"));
%>
<c:forEach items="${items}" var="item">
<jsp:include page="include.jsp">
<jsp:param name="item" value="${item}" />
</jsp:include>
</c:forEach>
include.jsp
${param.item}<br>
output:
foo
bar
waa