You don't need to do the intermediate assignment to user, it should be
sufficient to do:
-----------
    <c:forEach var="User" items="${userRows } "
varStatus="idx">
   <c:choose>
         <c:when test="${( idx.count+1)%2 ==0}">
               <tr class="contentCell1">
         </c:when>
         <c:otherwise>
               <tr class="contentCell2">
         </c:otherwise>
   </c:choose>
                      <td><c:out value="${User.createdByUserID} "  /></td>
                      <td><c:out value="${User.firstName} "  /></td>
                      <td><c:out value="${User.lastName} "  /></td>
                </tr>
   </c:forEach>
-------------------
Also, the convention is to keep var names lowercase, as in <c:forEach
var="user"...

-ed


On 6/21/06, Caroline Jen <[EMAIL PROTECTED]> wrote:
I am able to display a List of object returned from
the database using the Struts tags:
[code]
.....
<%@ page import=".....common.pojo.user.User" %>
....
....
<%
        List user =
(List)request.getAttribute("Users");
        pageContext.setAttribute("Users", user);
%>
.....
.....
<logic:iterate id="users" name="Users" type=".....
commom.pojo.user.User" scope="request">
        <tr>
              <td><bean:write name="users"
property="createdByUserID"/></td>
             <td><bean:write name="users"
property="firstName"/></td>
             <td><bean:write name="users"
property="lastName"/></td>
        </tr>
</logic:iterate>
......
[/code]

But, when I use JSTL tags to do the same thing, I
cannot display my data.  I mean, I do "not" get any
JSP error.  I can see each row in a table, but it is
complete blank in every single column for every single
row.  I "did" import the JSTL tag library.  And the
JSTL tag library exists and works in other JSPs.
Please help me to see what went wrong.  Here is my
JSTL code (I am typing my code and there may be typos.
 Anyway, no error is given in the browser.):

[code]
.....
<%@ taglib uri="/tags/core" prefix="c" %>
<%@ page import=".....common.pojo.user.User" %>
....
...
<c:set var="userRows" value="${requestScope.Users}" />
.....
     <c:forEach var="User" items="${userRows } "
varStatus="idx">
     <% User user = (User)pageContext.getAttribute(
"user" ); %>
     <c:choose>
           <c:when test="${( idx.count+1)%2 ==0}">
                 <tr class="contentCell1">
           </c:when>
           <c:otherwise>
                 <tr class="contentCell2">
           </c:otherwise>
     </c:choose>
                        <td><c:out
value="${user.createdByUserID} "  /></td>
                        <td><c:out
value="${user.firstName} "  /></td>
                        <td><c:out
value="${user.lastName} "  /></td>
                  </tr>
     </c:forEach>
......
[/code]

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to