• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Passing objects via form submit

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have an ArrayList object in a JSP page. I would like to pass it to another JSP page that is being served on another web app server.

I cannot set the object on the session object.

I'm submitting the form using JavaScript.

How do I do it?
 
Sheriff
Posts: 67641
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
You can't. The JSP is executed on the server and your array list object goes out of scope long before the user gets a chance to submit the form on the client.

Please read this article for a better understanding of how JSPs operate.
 
Bear Bibeault
Sheriff
Posts: 67641
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

Originally posted by Sunil Kumar Jakkaraju:

I cannot set the object on the session object.



Sure you can. It's easy.
 
Sunil Kumar Jakkaraju
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Bear,

I might not have framed my question properly.

What I need to accomplish is to submit a request to another web server from a JSP page.

Initially, at the time when the JSP page is rendered, it gets an ArrayList object. This object has to be passed while requesting to another web server. This object can be retained in the page by setting it to session. But it is not enough when this object needs to be passed to different web application running in different web server.

A URL http://anotherwebserver ortno/anotherwebapp/SomeServlet is called from a javascript submit. This servlet does some background processing using the ArrayList object.


How can this be done?
[ December 09, 2006: Message edited by: Sunil Kumar Jakkaraju ]
 
Bear Bibeault
Sheriff
Posts: 67641
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
You most definitely cannot pass an object from one server to another. The only means you have is to pass data as request parameters.

If you are submitting a form, you can set the values into hidden elements.
[ December 09, 2006: Message edited by: Bear Bibeault ]
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If he uses web services, think he should be able to?
 
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
Can we back up a minute here.
Although the original poster thought in terms of passing an ArrayList object, lets think of just passing an ordered set of values. That could be as simple as hidden form values with names that transmit the order.



etc etc

Naturally the target web app will have to extract the form values and put them in order in a new ArrayList object.

Bill
 
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Chengwei Lee:
If he uses web services, think he should be able to?



Using something like SOAP you can, but that's quite different from submitting a form through a JSP.
And just like RMI calls you're not in fact passing an object, but rather you're serialising an object and thus passing a copy of that object.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jeroen T Wenting:

... but rather you're serialising an object and thus passing a copy of that object.



More specifically, you're passing a textual (XML) representation of that object's data.
 
Ranch Hand
Posts: 472
Objective C Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Serialize and use URL encode maybe applying something like 64base up front.
reply
    Bookmark Topic Watch Topic
  • New Topic