I’m building some HTML in JavaScript to be passed back to a JSP and I was doing this:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<pre style='width: auto;'>" + comment.comment + "</pre></td>";
But I found some JSP tag to use as an alternative to using <pre> to solve my newLine problem:
var html = "<td id='comment-" + comment.id + "'class='wrappable' style='width:400px;'>"
+ "<ctl:breakNewline target='" + comment.comment + "'/></td>";
But it doesn’t seem to work. How is this caused and how can I solve this properly?
JSP is evaluates on the server, JavaScript on the client. No, this can’t work.
(Of course you can use JSTL to create your entire JavaScript code, but you can’t call JSP code from javaScript)