Discussions

General J2EE: A Question in the example of jstl

  1. A Question in the example of jstl (1 messages)

    out.jsp

    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <html>
    <head>
      <title>JSTL: Expression Language Support -- Expr Example</title>
    </head>
    <body bgcolor="#FFFFFF">

    <h3><c:out></h3>

    <table border="1">
      <c:forEach var="customer" items="${customers}">
        <tr>
          <td><c:out value="${customer.lastName}"/></td>
          <td><c:out value="${customer.phoneHome}" default="no home phone specified"/></td>
          <td>
            <c:out value="${customer.phoneCell}" escapeXml="false">
              <font color="red">no fucking cell phone specified</font>
            </c:out>
          </td>
        </tr>
      </c:forEach>
    </table>

    <h4><c:out> with Reader object</h4>
    <%
    java.io.Reader reader1 = new java.io.StringReader("<foo>Text for a Reader!</foo>");
    pageContext.setAttribute("myReader1", reader1);
    java.io.Reader reader2 = new java.io.StringReader("<foo>Text for a Reader!</foo>");
    pageContext.setAttribute("myReader2", reader2);
    %>
    Reader1 (escapeXml=true) : <c:out value="${myReader1}"/><br>
    Reader2 (escapeXml=false): <c:out value="${myReader2}" escapeXml="false"/><br>
    </body>
    </html>

    ${customers}"> where is the variable "customers" defined and initialized?
    Thanks.
  2. A Question in the example of jstl[ Go to top ]

    In this example the variable customers is already in the request or session before this page is called. It is unclear though why there is an unmatched c:out tag in the h4 tag near the end that does not specify any output.