File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes display array from servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "display array from servlet" Watch "display array from servlet" New topic

display array from servlet

Aalok Mishra
Ranch Hand

Joined: Dec 23, 2008
Posts: 41
Hi All,

I am passing an array from the servlet to the jsp page. The array is coming just fine but when I try to display an element from that array using javascript it doesnot alert it. i am a newbie to javascript hence cann't find out the reason. Can you tell me what should I change in my code so as to get the array element in alert.

Here is my code:

Note: the term ONCLIK is a javascript action

Thanks in Advance!

Thanks and Regards,
Aalok Mishra
InfoCepts, LLC
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63867

JavaScript knows nothing about the scoped variables that exist on the server. Please read this article to understand how JSPs work.

If you want data accessible form javaScript you'll need to create JavaScript literals or variables that contain it in your markup.

[Asking smart questions] [About Bear] [Books by Bear]
Aalok Mishra
Ranch Hand

Joined: Dec 23, 2008
Posts: 41
Thanks Bear!

That really helped a lot and solved my problem. Anyways now i am able to alert those values. I am putting in here the code so that others can take benefit of it.

[ December 30, 2008: Message edited by: Aalok Mishra ]
I agree. Here's the link:
subject: display array from servlet
It's not a secret anymore!