Storing values on clientside
Hi,
Can u tell me how to store the values that are retrieved from the serverside on the clientside
For ex i retrieved values from database using JSP and i want to store them in a Java script array so that they can be used afterwards for clientside working.
Thanks in advance
# 1 Re: Storing values on clientside
Set it as a request attribute and retrieve it in the JSP. It will be some jugglery of scriptlets and javascript.
Here's a snippet which might give you an idea.
<%
List dbList = (List)request.getAttribute("somereqparam");
%>
<script>
var jsArray = new Array();
// Somewhere in the script code
<% for(int i = 0; i < dbList.size(); i++) { %>
jsArray[<%=i%>] = "<%=dbList.get(i).toString()%>";
<% } %>
</script>