I am trying to set the CSS-name of a tag dynamically (based on the rowcount being odd or even). <c:forEach items="${result.rows}" var="currentRow" varStatus="resultStatus"> <c:choose><c:when test="${resultStatus.count % 2 == 0}"><c:set var="cssName" value="odd"/></c:when><c:otherwise><c:set var="cssName" value="even" /></c:otherwise></c:choose> <td class="<c:out value="${cssName}"/>"><c:out value="${currentRow.name}" /></td> I always end up with a page that says: <td class="even ">...</td> I tried to see if the value was wrongly set, but when I do the following check <c:if test="${cssName eq \"even\"}">YES IT IS EQUAL!</c:if> it returns true! So I think it must be in the <c:out /> tag. Already checked the code, but cannot see anything there. Using: JRun 4, JSTL binary distribution 1.0.1
I can't replicate this in Tomcat, unfortunately; I don't believe it's a bug with the Standard Taglib. Just as a test, have you tried the minimal case whereby you write something like <c:out value="even" /> or <c:set var="even" value="even" /> <c:out value="${even}" /> I'm curious what that prints out for you, and if there's any problem, what '<%= pageContext.findAttribute("even") %>' prints.
I tried what you suggested in a testpage and it works fine. I know found out that it is Macromedia Dreamweaver MX that inserts " " if you place <c:out value="${even}" inside the quotes of a class attribute for a css-class. And the most strange thing is: in the editor, it does not show that I found it out by opening the same .jsp file in a text-editor and there it was, the phantom " "! Nevertheless, thanks for your help!