Question

<%String content = content.getBody();%>

where "body" is a string containg html markup.

body="<?xml version="1.0" encoding="ISO-8859-1"?><html><head/><body><p> Hi Firstname Lastname,</p><p>You have requested to change your password</p><p>test content</p></body></html>"

when I display it on JSP using <%=content%>, it considers html markup and prints the content as expected as follows:

*Output: * Hi FirstName, lastName, You have requested to change your password. test content

However when I tried doing the same using JSTL's c:out as follows:

<c:out value="${content.body}"/>

It ignores html format and prints the content of string "body" with all the html tags like p,html etc. Basically, it considers it as plain string and displays the content. I want my JSP to apply html tags and display accordingly.

Could you please help me with this?

Was it helpful?

Solution

try

<c:out value="${content.body}" escapeXml="false" />

As <c:out> uses XML escaping for the characters '<' and '>'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top