In my Java code, I have an ArrayList
of String
s. I'd like to put this data in a JavaScript variable on a JSP page I'm working on. My first thought was to include it directly, e.g.:
var myArray = <%= arrayList %>;
Unfortunately, when executed, myArray
is a string in the format [a,b,c]
, not an actual JavaScript array. How do I get some data from a Java ArrayList
to a JavaScript array?