Reputation: 89
I have a called a Servlet and I am sending an ArrayList
with request attribute from Servlet to JSP. I am calling a js function from the same JSP in which I am passing the ArrayList
as a param to the js function. I want to retrieve the values from this ArrayList
.
Code as follow:
<c:if test="${currentPage lt noOfPages}">
<a onclick="OnNextButtonClick(${currentPage},'${al}');">
<Next>
</a>
</c:if>
//Here al is the ArrayList
<script type="text/javascript">
function OnNextButtonClick(currentPage,al)
{
alert("current page == " + currentPage );
alert("current page == " + al);
var arr = new Array();
var arr = al.split(',');
alert(arr);
}
This arr is giving me values as follows:
[com.package@1def,com.package@fkbe23,com.package@546fhfg]
I want the values stored at this location.
Can someone help me?
Upvotes: 0
Views: 1254
Reputation: 301
First of all List obj = dao.listimpl();this is java code you have pasted, try to paste the exact object which you trying to iterate.
Though i would recommend use a very lightweight javascript library Loadash which is very handy, when you are dealing with array/objects and looping through these items and many more util methods.
_.forOwn(obj, function(value, key) { } );
Loadash - forOwn
Iterates over own enumerable string keyed properties of an object and invokes iteratee for each property. The iteratee is invoked with three arguments: (value, key, object). Iteratee functions may exit iteration early by explicitly returning false
Upvotes: 1