how to read arrayList content using JSTL
11,542
It should be :
<c:forEach items="${alldata}" var="item">
<c:out value="${item.name}"/>
</c:forEach>
Note: No <jsp:useBean>
required.
Author by
Developer_H
Updated on June 04, 2022Comments
-
Developer_H almost 2 years
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
-
Developer_H over 13 yearsI tried it , but I got the following exception "According to TLD or attribute directive in tag file, attribute items does not accept any expressions" it's my first experience with JSTL :$ thanks skaffman
-
skaffman over 13 years@Developer_H: Sounds like you've got a very old version of the JSTL libraries, probably 1.0. You need 1.1 or higher.
-
Developer_H over 13 yearsactually yes , I was using <tlib-version>1.0 I've changed it to <tlib-version>1.1 , but got "javax.servlet.ServletException" :D seems i have incompatibility issue somewhere else (any ideas where it could be? ) .. I'll check it now , thanks for your help