Link to home
Start Free TrialLog in
Avatar of Nika Gudge
Nika GudgeFlag for United States of America

asked on

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
SOLUTION
Avatar of Bryan Butler
Bryan Butler
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nika Gudge

ASKER

for now i have one product in database and im trying to display its properties in table format.
one product object in res.product. i'm trying to display properties of this object.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
solved