• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 216
  • Last Modified:

How to display <br> from a string to html

I have bean class

public class X ......{
String htmlString;
public void getHtmlString()
{
return htmlString;
}
public void setHtmlString()
{
String htmlString_="Hello<br>Hello";
this.htmlString = htmlString_;
}

From the Jsp page I use
<bean:write name="X" property="htmlString"/>

The output of the jsp displays Hello <br> Hello.

Instead i need a output like
Hello
Hello

If i use <%= <brString> %> it works fine. It display
Hello
Hello

Instead if i use <bean:write> then it does not display in next line.



0
srivenky
Asked:
srivenky
1 Solution
 
sudhakar_koundinyaCommented:
string=string.replaceAll("&lt;","<");
string=string.replaceAll("&gt;",">");
0
 
esorfCommented:
Actually, this is by design.  bean:write escapes all HTML by default so that strings come out as they look, not as HTML tags.

Try adding filter="false" to turn off escaping.

<bean:write name="X" property="htmlString" filter="false"/>
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now