I find JSP works great in HTML but I often have problems using it to generate Javascript. This code isn't working, and in fact the page crashes when I try to inspect the element with Chrome's debugging tools:
var sensorData = [[
<c:forEach items="${tableData}" var="val" varStatus="status">
<c:set var="tempStr" value="X"/>
<c:choose>
<c:when test="${!fn:contains(val, tempStr)}">
<fmt:formatNumber value="${val}" maxFractionDigits="0"/>
</c:when>
<c:otherwise>
${val}
</c:otherwise>
</c:choose>
<c:choose>
<c:when test="${(status.index + 1) % width == 0 && !status.last}">
],[
</c:when>
<c:when test="${status.last}">
]
</c:when>
<c:otherwise>
,
</c:otherwise>
</c:choose>
</c:forEach>
];
Here I'd like to create a 2d array with tableData, an ArrayList. Eclipse is showing errors on the first <c:when>:
Syntax error, insert "]" to complete ArrayLiteral
Can anyone see what I'm doing wrong?