There is some JSP page and List:
List<Articles> listArticles = ListArticles.getArticles(1);
Iterator<Articles> iter = listArticles.iterator();
and then I iterate through this list and I add its elements to ArrayList
<%
ArrayList<String> arts = new ArrayList<String>();
while (iter.hasNext()) {
Articles currentArticle = iter.next();
arts.add(currentArticle.getTitle());
}
%>
and then I try print this ArrayList, but nothing happens (c:forEach simply don’t see “${arts}”)
<c:forEach var="listItem" items="${arts}">
c:out value="${listItem}" />
</c:forEach>
You need to add the
artsto the page context. JSTL tags don’t know about page level JSP variables, it works with the JSP scopes.Add this after you populate your
artsarrayand you should be fine.