• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 893
  • Last Modified:

Iteration loop counter in JSTL tag

<table class="TableBackgroundDB">
            <thead>
                    <tr class="TableHeaderRow">
                  <th>Name</th>
                  <th>Specification</th>
                </tr>
          </thead>      

                <c:forEach var="product" items="${res.product}" varStatus="rowCounter">
                <c:choose>
                      <c:when test="${rowCounter.count % 2 == 0}">
                        <c:set var="rowStyle" value="odd" />
                      </c:when>
                      <c:otherwise>
                        <c:set var="rowStyle" value="even" />
                      </c:otherwise>
              </c:choose>
                          
              <portlet:renderURL var="searchProductURL">
                <portlet:param name="action" value="viewProduct" />
                <portlet:param name="spec" value="${product.Specification}" />
                </portlet:renderURL>
               
                    <tr class="${rowStyle}">
                    <td><a href="${searchProductURL}">${product.name}</a><td>
                      <td>${product.Specification}</td>
                    </tr>
                    
                  </c:forEach>
          </table>
      </c:if>


output-  

Name    Specification
product                       product.ss1
0
Newton21205
Asked:
Newton21205
  • 3
  • 2
2 Solutions
 
Bryan ButlerCommented:
Are you sure ${res.product} has more than the one product?  Can you output the values to check?
0
 
Newton21205Author Commented:
for now i have one product in database and im trying to display its properties in table format.
0
 
Newton21205Author Commented:
one product object in res.product. i'm trying to display properties of this object.
0
 
Bryan ButlerCommented:
items="${res.product}" must not be right.  What about just:

items="$res"
0
 
Newton21205Author Commented:
solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now