I have JSP string array like
String[] valueArray = new String[valueList.size()];
valueArray = valueList.toArray(valueArray);
I want to use this in Javascript using JSTL
var array = new Array();
<c:forEach items="${valueArray}" var="item">
array.push("${item}");
</c:forEach>
somehow this does not work. it does not populated any values. Please help.
If the first set of codes are
scriptletsin your jsp file, you should change your second set of codes as something like:Or if they were a part of a java file (may be a servlet or an action class), you should add a line:
This will add your valueArray in your session, ready to be retrieved on your jsp.