aspose file tools*
The moose likes Struts and the fly likes Outputting html text 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 » Frameworks » Struts
Bookmark "Outputting html text" Watch "Outputting html text" New topic
Author

Outputting html text

Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
I have bean values that have html markup as part of the value. How do I display that html in struts without having the markup tags be outputted explicitly? In other words, I want the html to be rendered by the browser.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

How are you outputting them now? Just don't escape them?
Andy Holm
Ranch Hand

Joined: Jul 03, 2008
Posts: 86
Right now the legacy application outputs the values with a <bean:write>. In the database, the field values are things like:

Test Value

When it is outputted, the source of the web page shows:

<b>Test Value</b>

This all happens as part of the <bean:write> output. Is there another call I should be using?
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

http://struts.apache.org/1.2.x/userGuide/struts-bean.html#write

See the "filter" attribute. The documentation is your friend--read it early and often.

Note that simply setting it to false without any other back-end cleanup exposes the page to scripting attacks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Outputting html text