JSTL Create Alternating Table Row / Cell Background colors using odd and even % row calculations

Posted on 2005-04-12
Last Modified: 2012-08-14
Hi Everyone.  I'm just trying to create alternate / alternating  background colors for my list tables
using JSTL.  The varStatus.count field does show 1...2...3...4...5 (array occurs if quuerried) so this the input object is OK.
There must be something else missing.  Thanks  

1) First - Here's the css for the 2 table background color properties:

<STYLE TYPE="text/css">

Here's the JSTL that should change with the alternating rows.

<c:forEach var="item" items="${sessionScope.AValidArray}"  varStatus="status">
 <c:set var="cellColor">
 <c:when test="${status.count % 2 == 0}">colorBlue</c:when>
<TABLE class="cellColor">
<TR><TD>the table colors should alternate with each outoput row</TD></TR>


Note: When I <c:out value="${status.count}"/>  I do get 1...2...3...4...5..6..7..8..9..10...etc

Either the 'whenTest' or the 'cellColor' set up that is not working ? ? ? ?
Question by:paygo
    1 Comment
    LVL 7

    Accepted Solution

    Simple solution for you, you need to acquire the cellColor variable using the core tags:

    <TABLE class="<c:out value="${cellColor}" />">

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Envision that you are chipping away at another e-business site with a team of pundit developers and designers. Everything seems, by all accounts, to be going easily.
    Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo‚Ķ
    Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now