JSTL List Count Using varStatus

JSTL List Count Using varStatus

// Getting The List Size In JSP

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




Previous 1 2








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