wood burning stoves 2.0*
The moose likes JSP and the fly likes Passing an arrayList of JavaBean Object as hidden variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Passing an arrayList of JavaBean Object as hidden variables" Watch "Passing an arrayList of JavaBean Object as hidden variables" New topic
Author

Passing an arrayList of JavaBean Object as hidden variables

rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
Hi every body...

i have a JSP page..where i get an ArrayList of objects. These objects are of type javabean type...say of class CapacityReqdBean.java.

Now my requirement is that i want to pass this arraylist to servlet....but don't know how to do it.
can i pass it through hidden variable .

i am not in a position to use session..because on jsp page i would be having different radio buttons....and each button would be representing an arrayList.

Finally on click of a radio button....that corresponding arrayList has to passed to the servlet where it would be passed to a function.


how can i achieve this..please help me.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Short answer: no.

Browsers only send strings. You can serialize/de-serialize somehow, or send IDs and re-create on the server side somehow, but the browser will send only strings back to the server.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
The Servlet API provides the session for passing references to objects to various servlets and JSP within the same web application.

This is all very basic stuff, have your read a tutorial on the servlet API?

Hidden variables are used in HTML pages to attach name-value pairs of strings to HTML form submission.

Bill
rammie singh
Ranch Hand

Joined: Mar 26, 2009
Posts: 116
Hi william
actually i didn't want to use session.
But still can you mention which servlet API is used for this purpose.....may be i can get the result.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

rammie singh wrote:because on jsp page i would be having different radio buttons....and each button would be representing an arrayList.

That makes no sense. A radio button con only represent a single string value. How is it representing an array list?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

David Newton wrote:send IDs and re-create on the server side somehow.


Yes. it is an Easy way
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Passing an arrayList of JavaBean Object as hidden variables
 
Similar Threads
How to keep selected radio button after page refresh
How to pass the radio button attribute checked=true from the Java servlet to JSP
Just passed with 92% - great tips!
Array lists syntax in jsp
how to pass arraylist from jsp to java bean