I have a jstl file which consists of a javascript snippet.
<res:useJS target="exec-js">
new current.myfunction({
my_arg:{
<c:forEach items="${arguments.value}" var="dataresults" varStatus="loopcount">
<c:out value="\"${dataresults}\" ${!loopcount.last ? ', ' : ']'}"/>
</c:forEach>
});
<res:useJS>
But when I run it I get an error saying “invalid property id” and when I look at the content – something like this has been passed. "data_res1","data_res1",. I need to have double quotes in the results as that’s how I am parsing it in the javascript function. Any ideas on how this could be done?
<c:out>converts special characters to HTML entities to prevent injections.You can use StringEscapeUtils.escapeJavaScript from Apache commons to escape your string and then output the plain value with