jstl code issue

Posted by theJava on Stack Overflow See other posts from Stack Overflow or by theJava
Published on 2010-12-21T17:33:38Z Indexed on 2010/12/21 19:54 UTC
Read the original article Hit count: 271

Filed under:
|
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
 pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
.even {
 background-color: silver;
}
</style>
<title>Registration Page</title>
</head>
<body>

<form:form action="add.htm" commandName="user">
 <table>
  <tr>
   <td>User Name :</td>
   <td><form:input path="name" /></td>
  </tr>
  <tr>
   <td>Password :</td>
   <td><form:password path="password" /></td>
  </tr>
  <tr>
   <td>Gender :</td>
   <td><form:radiobutton path="gender" value="M" label="M" /> <form:radiobutton
    path="gender" value="F" label="F" /></td>
  </tr>
  <tr>
   <td>Country :</td>
   <td><form:select path="country">
    <form:option value="0" label="Select" />
    <form:option value="India" label="India" />
    <form:option value="USA" label="USA" />
    <form:option value="UK" label="UK" />
   </form:select></td>
  </tr>
  <tr>
   <td>About you :</td>
   <td><form:textarea path="aboutYou" /></td>
  </tr>
  <tr>
   <td>Community :</td>
   <td><form:checkbox path="community" value="Spring"
    label="Spring" /> <form:checkbox path="community" value="Hibernate"
    label="Hibernate" /> <form:checkbox path="community" value="Struts"
    label="Struts" /></td>
  </tr>
  <tr>
   <td></td>
   <td><form:checkbox path="mailingList"
    label="Would you like to join our mailinglist?" /></td>
  </tr>
  <tr>
   <td colspan="2"><input type="submit" value="Register"></td>
  </tr>
 </table>
</form:form>
<c:if test="${fn:length(userList) > 0}">
 <table cellpadding="5">
  <tr class="even">
   <th>Name</th>
   <th>Gender</th>
   <th>Country</th>
   <th>About You</th>
  </tr>
  <c:forEach items="${userList}" var="user" varStatus="status">
   <tr class="<c:if test="${status.count % 2 == 0}">even</c:if>">
    <td>${user.name}</td>
    <td>${user.gender}</td>
    <td>${user.country}</td>
    <td>${user.aboutYou}</td>
   </tr>
  </c:forEach>
 </table>
</c:if>
</body>
</html>

When i execute my jsp page, this piece of code does not show up at all. The full source code is below.

<c:if test="${fn:length(userList) > 0}">
    <table cellpadding="5">
        <tr class="even">
            <th>Name</th>
            <th>Gender</th>
            <th>Country</th>
            <th>About You</th>
        </tr>
        <c:forEach items="${userList}" var="user" varStatus="status">
            <tr class="<c:if test="${status.count % 2 == 0}">even</c:if>">
                <td>${user.name}</td>
                <td>${user.gender}</td>
                <td>${user.country}</td>
                <td>${user.aboutYou}</td>
            </tr>
        </c:forEach>
    </table>
</c:if>

© Stack Overflow or respective owner

Related posts about jsp

Related posts about jstl