Web tier: servlets, JSP, Web frameworks: How to Escape HTML tags in toString()

  1. How to Escape HTML tags in toString() (2 messages)

    I'm using Struts framework to develop an application and am having a problem getting HTML to "pass-through" from my Javabean. In the JSP file I'm using the <bean:write> tag to display a String 'getter' method.

    The getter method I'm calling aggregates the address so it shows as follows:

    addressline1 + "<br>"
    addressline2 + "<br>"
    city, state, zip + "<br>"

    The problem I'm having is with the "<br>" tags. They are showing up as "<br&rt;" instead of <br> in the HTML.

    Can anyone help with how to escape these tags?

    Thanks in advance,
  2. Hi,

    the "filter"-Attribute will preserve any embedded HTML formatting tags, e.g.
    <bean:write name="someBean" filter="false"/>

  3. Thanks that worked![ Go to top ]