Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass dynamic array content from javascript to jsp

 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How the jsp will get dynamic array content from javascript ?
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Turn the array into a string, put it into a hidden field, and submit it to the server.

Eric
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you be a bit more specific describing the problem? Are you trying to use the contents of a JavaScript array in the *same* JSP you're rendering?
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know what you're trying do, if you're trying to send an array of contents via ajax to a jsp page. or if you are trying to 'echo' javascript to the page that will give the jsp page some kind of object to work with (which isn't possible, atleast not that I know of).

But if you are processing each element of this array that you want to pass to a jsp page, you could just process each element and send it to the same page over and over again. Like so:



Hope this helps,

Justin">
 
indu yeturu
Ranch Hand
Posts: 123
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I created 4 dynamic arrays for dynamic table html form in javascript.
When I hit the submit button all the dynamic details will be submitted to server.
for that first I need to send all the dynamic array contents jsp.



I have something like this --- 4 types of arrays. What is the process to send these details to some "Submit_details.jsp" sothat from there - Insert into database.

Sending these details from javascript to jsp --- element by element or total dynamic array?
which is the way ?>
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to convert it to a string and submit it via a hidden element.

You wither loop through and or use join().

Eric
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic