How do I pretty print (ie. with indentation) XML data in the JSP? I have the following code:
<c:forEach items="${stuffs}" var="stuff">
<pre>
<c:out value="${stuff}" escapeXml="true"/><br/>
</pre>
</c:forEach>
But the problem is when ${stuff} is an unformatted XML, it will show in the jsp as one long XML data. I need it pretty-printed inside the <p> tag.
XSLT has a simple means of doing this via the
xsl:outputelement. If you can apply an XSLT, I suggest using a stylesheet like this (based on the identity transformation):