Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Sharing array with Javascript in JSP?

 
Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • 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.
 
Marshal
Posts: 67496
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic