Is there any way to pass an object as part of a form post from an html page? I would like to create an object through useBean, use it to populate a form, and pass it along with the form fields on the put request object.

Michael Wax

Two alternatives will work.

The first, which is the closest to what you are asking for, is:

  • serialize the object, which will give you a byte array;
  • convert the byte array to a string;
  • url encode the string to make sure that it contains no html-incompatible characters; and,
  • put the string into the form as a hidden field, which will be passed back on the post.
Of course, for large objects, this becomes impractical.

A better alternative would be to store the object on the server side (e.g., in a hashtable or in a database), and then put a key to the object in a hidden field on your form. This avoids the need to pass around potentially large objects.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact