Greetings, here is the problem. I have a page called entList.jsp that works with a collection:
<c:forEach var = "pack" items = "${packingList}"> </c:forEach>
Everything works fine, and the packageList parameter is passed as a request attribute by the action handler that invokes this page. In fact, packageList is of type Collection <GenericBean>.
It turned out that this page (the fragment that it stores) is actually very useful and can be used in many places with different collections. So I tried to include this page as follows (on another page):
<jsp:include page="entList.jsp"> <jsp:param name = "packingList" value = "${traffic.packingList}"/> </jsp:include>
However, now this fragment does not see the packageList argument. I tried to rewrite the fragment like this (since now it is a parameter):
<c:forEach var = "pack" items = "${param.packingList}"> </c:forEach>
But now it throws an exception, because it treats packingList as a string, not a collection. Therefore, right now the solution looks like this: set the required collection as an attribute in the code of the action handler:
// This is the original instance set by the action request.setAttribute("traffic", traffic); // And this is the additional one, to be used by entList.jsp request.setAttribute("packingList", traffic.getPackingList());
So the question is, can the jsp: param tag get the collection as a value? I read the documentation for JSP tags and it remains unclear - it seems that the only thing you can pass in this way is string parameters (or something that can be converted to string), but not complex objects.
source share