Reputation: 43
I have simple jsp page (page.jsp), and a simple java class (classWithArray) with an arraylist (list) in it.
How can I get access to the arraylist from jsp, for example to show it in a table?
Upvotes: 3
Views: 7592
Reputation: 46438
you can iterate over an ArrayList using c:forEach
tag from JSTL
Below is the sample code which iterates over an peopleList List.
<c:forEach var="person" items="${people.peopleList}">
<tr>
<td>${person.name}</td>
</tr>
</c:forEach>
use page tag to import a java.util.List in your JSP page use
<%@ page import="java.util.List" %>
Upvotes: 1
Reputation: 236150
Use JSTL's forEach
tag to iterate over a collection (an ArrayList
in this case in particular) inside a JSP, take a look at this post for more details.
Upvotes: 1