Reputation: 47
In my controller I have code like this:
List<FeesReceiptIntegrationModel> FRIList = feesReceiptIntegrationService.listInstituteWiseCollectionSummary(model, request);
model.addAttribute("FRIList", FRIList);
I want to access this FRIList and its fields in Scriptlet of JSP page. I tried something like this:
String fcash = request.getParameter(FRIList.cashamount);
but it does not work.
List myMap = (ArrayList) request.getAttribute("FRIList.cashamount");
I don't want to access this via JSTL tags but I would like to access this only in scriptlet.
Can anybody tell me how this can be achieved?
Upvotes: 4
Views: 6984
Reputation: 8187
You cant print the values in the list as it is, you need to iterate them after you get the list from the model
. As said,
I don't want to access this via JSTL tags but I would like to access this only in scriptlet
<% List<FeesReceiptIntegrationModel > myMap = (ArrayList<FeesReceiptIntegrationModel >) request.getAttribute("FRIList");
for(FeesReceiptIntegrationModel obj : myMap ){
obj.getcashamount(); // your getter method here
}
%>
but it is not advisable to use the scriptlets
, please have a look at How to avoid Java code in JSP files?
Upvotes: 0
Reputation: 13844
Using scriplets is a bad idea. Try to avoid using java codes inside JSP page.
You can use JSTL c:forEach for your purpose
Simple example
<c:forEach items="${FRIList}" begin="0" end="1" var="test">
${test.cashamount}
</c:forEach>
Upvotes: 1