Reputation: 3549
Hi I am trying to print the list of strings stored in ArrayList
object using JSTL, here is my jsp page:
<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
List<String> al = new ArrayList<String>();
al.add("testing1");
al.add("testing2");
al.add("testing3");
al.add("testing4");
al.add("testing5");
System.out.println("hello"+ al);
%>
<c:forEach var="alla" items="${al}" >
<c:out value="Hello text"></c:out>
<c:out value="${alla}"></c:out>
</c:forEach>
when i see output it is not showing any thing on the browser, I have printed it using foreach
it is showing the result where as in JSTL
it is not printing ?
Upvotes: 0
Views: 2228
Reputation: 8197
jstl
is used to print the objects from the session
or request
scopes. you did not set your List al
either of those .
Try adding it to the session
and then access it through jstl
HttpSession session = request.getSession();
session.setAttribute("al", al);
and use c:forEach
to print it in your page.
See also
Upvotes: 4