How do I alternate HTML table row colors using JSP?
My CSS looks something like:
tr.odd {background-color: #EEDDEE}
tr.even {background-color: #EEEED
I don't use JSP, so I can't give you an answer in your language, but here's what I do (using pseudo code)
counter = 0
foreach (elements)
counter = counter + 1
output: ...
Personally, I name the classes "row0" and "row1", which lets you alternate between them with a simple modulus calculation, also, if you decide to have rows alternating in triples or quads (instead of pairs), you can easily extend it to row2, row3 and change your output code to be counter % 4, etc.