Bug 12956

Summary: c:out always outputs a   at the end
Product: Taglibs Reporter: Dieter van Baarle <dvbaar>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: CLOSED WORKSFORME    
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   

Description Dieter van Baarle 2002-09-24 12:51:52 UTC
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&nbsp;">...</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
Comment 1 Shawn Bayern 2002-09-24 17:52:29 UTC
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.
Comment 2 Dieter van Baarle 2002-09-25 14:09:30 UTC
I tried what you suggested in a testpage and it works fine.
I know found out that it is Macromedia Dreamweaver MX that inserts "&nbsp;" 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 &nbsp; 

I found it out by opening the same .jsp file in a text-editor and there it was, 
the phantom "&nbsp;"!

Nevertheless, thanks for your help!