aspose file tools*
The moose likes JSP and the fly likes character translation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "character translation" Watch "character translation" New topic
Author

character translation

Gregg Kelly
Greenhorn

Joined: Feb 10, 2006
Posts: 6
I have a string being returned from a bean that contains a HTML formatted message. something like:

"<font color=#00FF00>This is a message"

It appears during processing that the angle brackets are being translated into < and > codes. How do I disable this translation??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

How are you emitting the string on the page?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gregg Kelly
Greenhorn

Joined: Feb 10, 2006
Posts: 6
I should have provided some env specs. I'm using:
tomcat 5.5.12
struts 1.2.8
os - solaris 10

I'm using the struts framework to populate a request bean for a jsp page to retrieve the value. I have verified that the form bean propertyt is correctly assigned. In the cited example the property is:
"<font color=#00FF00>This is a message"

I use a jsp page for presentation -- the snippet from the jsp:
<h1>
<bean:write name="xxxForm" property="mystr"/>
</h1>

The code you see on the browser is:
<h1>
*lt;font color=#00FF00*gt; This is a message
</h1>

replace * with &. So it appears the data transfer from the form bean to the JSP page goes through a translator. Is this correct??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

By default the <bean:write> tag will html-encode the output. I think you can use the filter attribute to turn it off.

It's very uncommon -- and not a good separation of concerns -- to emit HTML from the back end in this way. That's why tags like <bean:write> and the JSTL <cut> tag encode the output by default.

I'd also suggest that you look into using CSS for stlying rather than deprecated tags like <font>.
[ February 11, 2006: Message edited by: Bear Bibeault ]
Gregg Kelly
Greenhorn

Joined: Feb 10, 2006
Posts: 6
Thanks Bear!! Setting filter="false" did the trick.

I agree with your design observations and recommendations. This data field happens to be a one-off case where it is much more efficient to construct it at the back-end.

Thanks again for your help.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61433
    
  67

You're welcome Gregg, and welcome to the Ranch!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: character translation