Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Outputting html text

 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you outputting them now? Just don't escape them?
 
Andy Holm
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic