I'm having a servlet in which I have stored an array within the session scope as follows,
session.setAttribute("pageNames",pageNames);
Now this servlet transfers the controll to an JSP page which calls the function 'getPage()' while loading as follows,
<body id="qwer" onload="getPage('<%=(String[])session.getAttribute("pageNames")%>'>
The javascript code for 'getPage()' is as follows,
function getPage(pageNamesArray)
{
var ele = document.getElementById('app');
for(var i=0;i<10;i++)
{
var imageLabel = document.createElement("label");
imageLabel.innerHTML = pageNamesArray[i];
ele.appendChild(imageLabel);
}
}
I expected that I would be getting the name of the first 10 values from 'pageNames' array that I had stored in the session, but instead I'am getting following output,
[Ljava.lang.String;@17a8undefinedundefinedundefined
I tested the code in my servlet and found that the array 'pageNames' is filled with more than 40 values.
Can anyone suggest me what to do to print the values of the array pageNames from within the JSP page? Thanks in advance.