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

Accessing Javascript object in jsp

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have collected data in an array of objects (which again has an array with data). I need to send this as a request parameter to another JSP file where all this data will be written to a file.

My question is: How do I pass this object in the request and read it in the following JSP.
I have tried putting it as a hidden field and doing a getParamterValues(); but it doesn not give me the correct data.

If anyone has faced a similar situation, please tell me what I can do.
 
Sheriff
Posts: 67746
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

I have tried putting it as a hidden field and doing a getParamterValues(); but it doesn not give me the correct data.



How are you serializing this complex data (which I assume is a Javascript object, right?) into the hidden parameter?
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought that the array of objects would be passed as a String array of objects, but didn't happen.

Should I explicitly copy each element in this array and send it in the request? Doesn't sound like a very good solution.
 
Bear Bibeault
Sheriff
Posts: 67746
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
HTTP request parameters are the only means that you have to comminicate with the server, so explicitly passing the values in the array is your only choice. How you serialize the data into the hidden parameter string(s) could be done in a number of ways.

Backing up... why do you want to send a huge chunk of Javascript data to the server in the first place? Where is the data coming from? What defines it? And what will the server do with it?

Knowing this might allow us to come up with better solutions.
 
Harsha Pherwani
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its like this:
A lot of data can be manipulated (added can be added / removed) in the UI. For every addition / removal, I do not want my page to be submitted, read the data and save in the session and come back to this screen for more manipulation.

So I save all the data in Javascript objects and on a final hit of a button I want to write it to a file. Thats when I have to retrieve the data. This way the end-user does not have to wait a long time; since manipulating the javascript objects on the client side is a very fast.

I hope I have explained it to you well enough.
 
reply
    Bookmark Topic Watch Topic
  • New Topic