You can't do it directly, but using a loop and JavaScript's literal
initializer you can create the JS code to do it.
(Note: this is not the most efficient way to do it, you should use a
StringBuffer to build the variable.)
String jsVar = "[" + array[0];
for (int i = 1; i < array.length; i++)
jsVar = jsVar + "," + array[i];
out.println("var jsArray = " + jsVar + "];";
There is nothing special to do on the client side. Just make sure the line
is output within the HEAD section of the page and your array (called
jsArray) will be declared and populated when the page is loaded in the
browser.
-----Original Message-----
From: Richard Johnstone
[mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 02, 2002 9:02 AM
To: [EMAIL PROTECTED]
Subject: A bit off topic
I know this is a bit off topic but I can't seem to get an answer from
anywhere.
Has anyone been able to load a Java array from a servlet into a
javascript array within the HTML page generated by the servlet?
Is it possible?
--
To unsubscribe: <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>