This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes c:out  trim problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "c:out  trim problem" Watch "c:out  trim problem" New topic

c:out trim problem

Prasad murali

Joined: Feb 07, 2007
Posts: 4
I have a message to display using <cut>

<cut value="${message}"/>

where the message is a request attribute containing the string
"The Lake". This string contains 3 whitespace between the words 'The' and 'Lake'. I need to display the message in the same way it is present but <cut tag trims the whitespaces between the words and the string is displayed with only 1 whitespace between them.

Christophe Verré

Joined: Nov 24, 2005
Posts: 14687

I don't think that cut trim anything. I think that the HTML gets rid of the extra spaces.
You could try to use JSTL's fn:replace function, to replace spaces with the HTML code "nbsp".

[My Blog]
All roads lead to JavaRanch
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

One thing to keep in mind is that HTML renderers (per their spec) will trim whitespace. Before looking at the cut tag, or any other server side technology, always make sure to view the HTML source to see if the whitespace is actually being trimmed before it reaches your browser.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Prasad murali

Joined: Feb 07, 2007
Posts: 4
Thank you guys for the response !!
I agree. Here's the link:
subject: c:out trim problem
Similar Threads
how to map list of object from jsp to command object in spring
getting value from request object
why c:forEach only display the conten of first row?
html interpretation
questions about JSTL variables