Output a table : HTML Output « JSTL « Java

Output a table

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core-rt" 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}" />


JSTL-HTML-Table.zip( 851 k)

Related examples in the same category

1.Out with Tag Escaping Examples
2.Simple calculation and output
3.Out Default Examples