• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

New to Javascript - How to work with a given array in a javascript function

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Everybody:

I'm trying to draw a map using google visualization. For setting different places in the map, I need to pass an array to the javascript method, but I can't get it working

This is the code I'm trying to use


If I put it that way, I get the next error:

Error: missing ] after element list

Line: 122, Column: 34
Source Code:
var list=[Ljava.lang.String;@129efd0;

Does anybody know how can I store in a local array variable in javascript the value of the array in j? I've spent a lot of time googling it but I haven't got anything

Thank you very much in advance
 
author and iconoclast
Posts: 24208
47
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that Javascript runs in the web browser, while the variable you're trying to look at exists in the Java code generated from the JSP, which runs on the server; by the time the Javascript runs, the Java variable no longer exists. What you need to do instead is write Java code to explicitly generate a Javascript array out of the Java array data. The Java code will run on the server when the page is executed, and it should create the proper Javascript code to initialize a Javascript array containing the same elements. That Javascript code will be embedded in the page, and it will be downloaded to the browser and executed there.
 
Sheriff
Posts: 67762
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please read this article to understand how JSPs operate.
 
antonio alcantara
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you very much for your help. Now I know a little more about JSP

Just in case another one has the same problem, here is the solution

 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic