I have come across a scenario where I have set my attribute in the Action class:
request.setAttribute("itemList", itemList); /* valid List item - confirmed */
and on JSP, I tried to use it within forEach
tag as
<c:forEach items="${itemList}" var="individualItem">
<!-- rest of the code -->
It evaluated as a null item. But I added a small scriptlet before this tag:
<% List<MyItem> itemList = (List<MyItem>)request.getAttribute("itemList"); // evaluates as my valid item list
List<MyItem> itemList = (List<MyItem>)pageContext.getSession().getAttribute("itemList"); // evaluates as NULL
%>
Does this mean that I am better off using pageContext or session Attribute rather than request Attribute on my front end? Or is there a rule?
KR,