JSTL ForEach Loop with Begin/End Step : ForEach « JSTL « Java Tutorial






<%@ taglib prefix="c"    uri="http://java.sun.com/jstl/core" %>

<c:set var="names" value="Peter, Pat, Mark, Tracy" scope="page" />

<html>
  <head>
    <title>forEach and status</title>
  </head>

  <body>
    <h1>The forEach tag exposes a scoped variable called 'count', which
    is the position of the current iteration of the collection.</h1>

    <h2>(Note, it is <i>not</i> the position of the element in the
        underlying collection)</h2>

    <c:forEach items="${pageScope.names}"
               var="currentName"
               varStatus="status"
               begin="0"
               end="3"
               step="2"
    >
      Family member #<c:out value="${status.count}" /> is
        <c:out value="${currentName}" /> <br />
    </c:forEach>
  </body>
</html>
  Download:  JSTLForEachBeginEndStep.zip( 1,021 k)








24.7.ForEach
24.7.1.JSTL ForEach Loop
24.7.2.JSTL ForEach Loop with Begin/End Step
24.7.3.JSTL Integer Controlled Loop
24.7.4.Use JSTL ForEach Tag to Loop Through a String
24.7.5.JSTL ForEach Status Count
24.7.6.JSTL ForEach Loop With Step
24.7.7.Reference Array by Index
24.7.8.Use For Each to Loop Through Comma Delimited String
24.7.9.Use ForEach to Loop Through ArrayList
24.7.10.Use JSTL ForEach to Loop through a Vector
24.7.11.Check Even Odd Number in ForEach Loop