Replacing Newline Characters in Java and JSTL

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<% pageContext.setAttribute("newLineChar", "\n"); %>

<p class="text-muted">
    ${fn:replace(myText, newLineChar, "<br />")}
</p>

Leave a Comment

Your email address will not be published. Required fields are marked *