[Solved] Passing an array from Java (JSP) to jQuery

Use a JSON library for Java. Then serialize your ArrayList to JSON: ArrayList wordslist = new ArrayList(); wordslist.add(“Hello”); wordslist.add(“again”); String json = (new JSONArray(wordslist)).toString(); Echo the JSON text at the appropriate place in your JavaScript code. E.g. $(document).ready(function(){ var arr = <%= json %>; $.each( arr, function(i, l){ alert( “Index #” + i + “: … Read more