JSTL forEach List Iteration

JSTL List Example

// JSTL c:forEach Example
    

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.ArrayList"%>
<%
    ArrayList<String> numList = new ArrayList<String>();
    numList.add("1");
    numList.add("2");
    numList.add("3");
    request.setAttribute("numList", numList);
%>
<html>
<body>
    <c:forEach items="${numList}" var="item">
        ${item}
    </c:forEach>
</body>
</html>
Output
1 2 3




Previous 1 2








Your email address will not be published. Required fields are marked *