I would like to output a string in a JSP page. The string contains HTML tag. How do I display the HTML version of the string in JSP?
e.g.
`String str = "<b><u>bold and underlined</u></b>"`;
In JSP, I use <%=str%>
Instead of displaying the HTML version of the string (with bold and underlining of the text), the above string is displayed. Can you help?
I also tried
<% out.print(str); %>
But didnt worked for me.
Better to use JSTL, something like:
<c:out value="${str}" escapeXml="false"/>
If str
is coming in request then
<c:out value="${param.str}" escapeXml="false"/>
Here escapeXml="false"
will instruct that html/xml tags should be evaluated and not escaped.
don't know weather this helps..
By entering the string in the following manner allows you to show the code in a text area...
String str = "<textarea><b><u>bold and underlined</u></b></textarea>";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With