<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%
synchronized (pageContext) {
String[] names = {"A", "B", "C", "D"};
pageContext.setAttribute("names", names, PageContext.PAGE_SCOPE);
}
%>
<html>
<head>
<title>forEach and status</title>
</head>
<body>
<c:forEach var="currentName" items="${pageScope.names}" varStatus="status">
Family member #<c:out value="${status.count}" /> is
<c:out value="${currentName}" /> <br />
</c:forEach>
</body>
</html>
|