Reputation: 33
I want to read the arrayList objects Attributes that is assigned to request object from JSTL how can I do this? i tryed the following
here is the servlet code:
ArrayList<Employee> al = new ArrayList<Employee>();
/* code for filling the ArrayList with objects from class Employee */
request.setAttribute("alldata", al);`
In my JSP page:
<jsp:useBean id="alldata" class="java.util.ArrayList" scope="request">
<c:forEach items="alldata" var="item">
<c:out value="item.getName()"></c:out>
</c:forEach>
</jsp:useBean>
but it's not working,
Thanks in advance
Upvotes: 3
Views: 11906
Reputation: 403491
It should be :
<c:forEach items="${alldata}" var="item">
<c:out value="${item.name}"/>
</c:forEach>
Note: No <jsp:useBean>
required.
Upvotes: 3