• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Sharing array with Javascript in JSP?

 
Judy Herilla
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65118
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • 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 ]
 
Yashnoo lyo
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/////////////////////////////]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic