Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

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
[303 byte] By [subhakar_nani] at [2007-11-11 8:04:12]
# 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>
aniseed at 2007-11-11 22:36:35 >