Search code examples
javascriptjavajspjspx

JSP getting object from backend and manipulating in JS


I'm trying to get an array of objects in JSP, the problem is I need to manipulate the object I get later in JS, so I'm doing:

<c:forEach items="${ids}" var="idsP">
    <script>
        var object = ${idsP};
        console.log(object);      
    </script>
</c:forEach>

The problem with this code is that I get the reference to the instance of the object, so I'm getting in the console output:

co.com.processonline.entities.documentManagement.DocumentalTypeInstance@5dedbbe

If I try to get each attribute individually it works fine, but I need to get all the attributes in the object, Is there a way I can do that?

Thanks


Solution

  • You need to parse to json before print in your JSP