I am trying to generate JavaScript code using a Strut tag. However, the inserted content contains newline characters which should be output escaped as \n
.
index.jsp:
<script type="text/javascript">
document.getElementById("content<s:property value="id"/>").innerHTML = converter.makeHtml("<s:property escape='true' value='content' />");
</script>
The expected result should be:
<script type="text/javascript">
document.getElementById("content6302").innerHTML = converter.makeHtml("> asdfasdf \n asddfadf");
</script>
The actual result is:
<script type="text/javascript">
document.getElementById("content6302").innerHTML = converter.makeHtml("> asdfasdf
asddfadf");
</script>
I.e. asddfadf");
is printed on a new line but should be \n asddfadf");
within the same line.
How can I get the escaped form \n
in the generated HTML?