jsp alternate table rows

Hi - I am trying to display different backgrounds for alternate rows, so I updated the jsp as below and it did not work,
so what should i change.
<table class="tblcompare">
<tbody>
<c:forEach items="${orgRiskMap}" var="orgRiskMap">                                    
      <c:forEach var="riskForm" items="${orgRiskMap.value}" varStatus="loop">
                  <tr class="${loop.index % 2 == 0 ? 'even' : 'odd'}">
                        <td class="cellfeat">${riskForm.getRiskDescription()}</td>
                        <td>${riskForm.getRiskCreatedDate()}</td>
                        <td>${riskForm.getRiskLevelId()}</td>
                        <td>${riskForm.getRiskOwner()}</td>
                        <td></td>
                        <td></td>
                  </tr>
      </c:forEach>                                                      
</c:forEach>
</tbody>
 </table>

and css file is like below

.tblcompare tbody tr.odd td {
      background: #efefef;
}

.tblcompare tbody tr td.cellfeat, .tblcompare tbody tr.odd td.cellfeat {
      background: #dcdcdc;
      padding: 2px 0 2px 10px;
      font-size: 1.2em;
      font-weight: bold;
      color: #444;
      text-align: left;
}
shragiAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
Try:
.tblcompare tbody tr td {
      background: #dcdcdc;
      padding: 2px 0 2px 10px;
      font-size: 1.2em;
      font-weight: bold;
      color: #444;
      text-align: left;
}

.tblcompare tbody tr.odd td {
      background: #efefef;
}

Open in new window


If you only care about browser with CSS3 support, you could simply use:
td:nth-of-type(odd) {
  background-color:#efefef;
}
td:nth-of-type(even) {
  background-color:#dcdcdc;
}

Open in new window

http://webdesign.about.com/od/css3/qt/alternating-row-styles-tables.htm

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shragiAuthor Commented:
The solutions did not work.
But if i write something like below it is working so I need a variable where I can set class = "odd" or class as nothing

<tbody>
<c:forEach items="${orgRiskMap}" var="orgRiskMap">                                    
      <c:forEach var="riskForm" items="${orgRiskMap.value}" varStatus="loop">
                  <tr class="odd">
                        <td class="cellfeat">${riskForm.getRiskDescription()}</td>
                        <td>${riskForm.getRiskCreatedDate()}</td>
                        <td>${riskForm.getRiskLevelId()}</td>
                        <td>${riskForm.getRiskOwner()}</td>
                        <td></td>
                        <td></td>
                  </tr>
                  <tr>
                                      <td class="cellfeat">24H Support</td>
                                      <td><img src="images/icon_20.png" alt="No" /></td>
                                      <td><img src="images/icon_9.png" alt="Yes" /></td>
                                      <td><img src="images/icon_9.png" alt="Yes" /></td>
                                  </tr>
      </c:forEach>                                                      
</c:forEach>
</tbody>
shragiAuthor Commented:
fixed with jquery

$(document).ready(function()
{
  $("tr:even").css("background-color", "#000000");
});
hieloCommented:
Try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>
<style type="text/css">
<!--
tbody tr td {
  background-color:#efefef;
}
tbody tr.odd td{
  background-color:lightgreen;
}
-->
</style>

</head>
<body>
<table summary="">
<thead>
<tr>
	<th>A</th>
	<th>B</th>
	<th>C</th>
	<th>D</th>
	<th>E</th>
	<th>F</th>
</tr>

</thead>
<tbody>
<c:forEach items="${orgRiskMap}" var="orgRiskMap">                                    
      <c:forEach var="riskForm" items="${orgRiskMap.value}" varStatus="loop">
                  <tr class="odd">
                        <td class="cellfeat">${riskForm.getRiskDescription()}</td>
                        <td>${riskForm.getRiskCreatedDate()}</td>
                        <td>${riskForm.getRiskLevelId()}</td>
                        <td>${riskForm.getRiskOwner()}</td>
                        <td></td>
                        <td></td>
                  </tr>
                  <tr>
                                      <td class="cellfeat">24H Support</td>
                                      <td><img src="images/icon_20.png" alt="No" /></td>
                                      <td><img src="images/icon_9.png" alt="Yes" /></td>
                                      <td><img src="images/icon_9.png" alt="Yes" /></td>
                                      <td></td>
                                      <td></td>
                                  </tr>
      </c:forEach>                                                      
</c:forEach>
</tbody>
</table>
</body>
</html>

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.