Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
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 REST with Spring (video course) this week in the Spring 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: 14688

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
It's not a secret anymore!