The Java EE 5 Tutorial

Flow Control Tags

The XML flow control tags parallel the behavior described in Flow Control Tags for XML data streams.

The JSP page tut-install/javaeetutorial5/examples/web/bookstore4/web/books/bookcatalog.jsp uses the forEach tag to display all the books contained in booklist as follows:

<x:forEach var="book"
        <c:set var="bookId">
            <x:out select="$book/@id"/>
        <td bgcolor="#ffffaa">
             <c:url var="url"
            value="/bookdetails" >
                <c:param name="bookId" value="${bookId}" />
                <c:param name="Clear" value="0" />
            <a href="${url}">
            <strong><x:out select="$book/title"/>&nbsp;
         <td bgcolor="#ffffaa" rowspan=2>
             <c:set var="price">
                <x:out select="$book/price"/>
            <fmt:formatNumber value="${price}" type="currency"/>
         <td bgcolor="#ffffaa" rowspan=2>
         <c:url var="url" value="/catalog" >
            <c:param name="Add" value="${bookId}" />
         <p><strong><a href="${url}">&nbsp;
            <fmt:message key="CartAdd"/>&nbsp;</a>
         <td bgcolor="#ffffff">
         &nbsp;&nbsp;<fmt:message key="By"/> <em>
            <x:out select="$book/firstname"/>&nbsp;
            <x:out select="$book/surname"/></em></td></tr>