• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Sharing array with Javascript in JSP?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to make an array that is generated from a checkbox group in an HTML request persist through
multiple calls to the server, without setting it n the session.
I can get the array in my JSP from the request.getAttribute, but how can I pass this into Javascript,
or set it so that it gets sent up to the server again? Is it possible?
Thanks.
 
Sheriff
Posts: 67750
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
Johanna, I'm nit sure exactly what you are trying to do, but the following may help.
If you have a Java array that is in scope during JSP execution, you can create a corresponding JavaScript structure. Perhaps something along the lines of:

I don't know if that really addresses your problem or not, but I thought I'd throw that out in case it helps.
bear
[ April 16, 2002: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:
I come across the same problem.But I can't do this use this method.
I want to send array from send.jsp to get.jsp.
///////////////////////////send.jsp//////////////////////////////

//////////////////////////get.jsp////////////////////////////////////

I want to get all the array when I click the button in get.jsp.But what I get is "undefine,undefine,undefine,yashnoo".
Why?
How to do this or is there any error in my code ?
Thks!
 
Yashnoo lyo
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want get the array when I click the button in get.jsp.
////////////////////////////get.jsp/////////////////////////////]
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If this was my problem I would write Javascript to create the array outside of any JS function. Here is an example - created inside <script language="JavaScript"> by Java print statements.

You say:

I want get the array when I click the button in get.jsp.


but remember, you click the button on the browser side in HTML written by the JSP - sometimes people new to JSP don't keep in mind how separate the browser and JSP actions are.
Bill
 
sunglasses are a type of coolness prosthetic. Check out the sunglasses on this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic