Skip to content Skip to sidebar Skip to footer

Convert Arraylist To Javascript Array

I am sending an arrayList from a java file to a .jsp file In order to receive that array I used the following code var words = [

Solution 1:

Possible fix (Bad fix):

var words = 
    [
        <c:forEach items="${requestScope.WordList}" var="word" 
         varStatus="status">
          "${word}"<c:iftest="${not status.last}">,</c:if>
        </c:forEach>
    ];

OR

Convert the Java ArrayList to JSON String, and use JSON.parse() to get Javascript object.

Post a Comment for "Convert Arraylist To Javascript Array"