I'm using JSTL to generate a JavaScript object in a bit of inline script in a JSP, like this:
<script>
var data = [
<c:forEach items="${MyData}" var="Datum" varStatus="status">
{
foo: ${Datum.foo},
bar: '${Datum.bar}'
}<c:if test="${not status.last}">,</c:if>
</c:forEach>
];
</script>
and Eclipse is totally unable to validate it. The HTML it generates is correct - so how do I make Eclipse stop trying to interpret/validate the JavaScript?
I've come across a number of similar questions here on SO, but none of them worked - including going to Preferences -> Validation and checking the "Suspend all validators" box!
'inDatum.bararen't going to get escaped to fit a JS string literal and you'll have script-injection security holes.bar: '${fn:replace(Datum.bar, "'", "\\'")}'for exactly the problem you mentioned. The strings aren't from user input anyway...bar: .... It will crash IE.<c:if test="${not status.last}">,</c:if>? That omits the trailing comma. :)bar: '${Datum.bar}',<-- that's a trailing comma right there