Link to home
Start Free TrialLog in
Avatar of srivenky
srivenkyFlag for United States of America

asked on

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.



ASKER CERTIFIED SOLUTION
Avatar of sudhakar_koundinya
sudhakar_koundinya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of esorf
esorf

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"/>