wood burning stoves 2.0*
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
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

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] [Bear's FrontMan] [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: http://aspose.com/file-tools
 
subject: display array from servlet
 
Similar Threads
Using EL to retrive data from Arraylist
trying to submit a form using hyperlink (href)
how to map list of object from jsp to command object in spring
javascript error: object expected
JSF TreeMap Iteration Problem Using JSTL In XHTML