Count to 10 Example: tracking even and odd : Loop « JSTL « Java

Count to 10 Example: tracking even and odd

<%@ taglib uri="" prefix="c" %>
<%@ taglib uri="" prefix="c-rt" %>
    <title>Count to 10 Example(tracking even and odd)</title>

    <table border="0">
      <c:forEach var="i" begin="1" end="10" varStatus="status">
        <jsp:useBean id="status"
        type="javax.servlet.jsp.jstl.core.LoopTagStatus" />

          <c-rt:when test="<%=status.getCount()%2==0%>">
            <c:set var="color" value="#eeeeee" />

            <c:set var="color" value="#dddddd" />

          <td width="200" bgcolor="<c:out value="${color}"/>"> 
          <c:out value="${i}" />

       851 k)

Related examples in the same category

1.JSTL: Conditional Support -- Simple Conditional Execution Example
2.JSTL Tag collaboration with a fixed loop
3.JSTL: fortokens
4.JSTL: another for each and status
5.JSTL: for each and status
6.JSTL: for each and scoped variable
7.JSTL: for each loop
8.JSTL: for each
9.Count to 10 Example using JSTL
10.JSTL For Each
11.JSTL Form Value and ForEach Loop