Reputation: 2472
How can I print a newline ("\n" or "\r\n" or "\n\r"). Which is the right one to be understood by a browser?) using JSTL or EL? I want to really print a newline (not a <BR>
), since I need to place it in a javascript section in a HTML file.
Upvotes: 1
Views: 9238
Reputation: 6062
You are asking the wrong question in your main post, and you later added it in a comment (perhaps you should edit your post to reflect the information in the comment?):
I need to put a \n after a // <![CDATA[ to end the comemnt before actaul JS code starts.
The easiest way to fix your issue is to comment out the CDATA
using a block comment like this:
/* <![CDATA[ */
This will allow you to continue your code on the same line and it will not be part of the comment.
/* <![CDATA[ */ var foo = "var";alert( foo ); /* ]]> */
Upvotes: 1
Reputation: 7
Try the below concept and it works.
<c:set var="String1" value="line1 line2 line3 line4" />
<c:set var="String2" value="${fn:split(String1, ' ')}" />
<c:set var= "new" value="<br />" />
<c:out value="${String2[0]}${new}" escapeXml="false" />
<c:out value="${String2[1]}${new}" escapeXml="false" />
<c:out value="${String2[2]}${new}" escapeXml="false" />
<c:out value="${String2[3]}${new}" escapeXml="false" />
Upvotes: -1
Reputation: 6383
Try the xml entities for this:
for a newline and
for carriage return.
Upvotes: 3