hi all, is it possible to pass an Object from one jsp page to another on form sumbit ?? wat i want is, when a click on the link of jsp page i want to submit a form and pass an Object which i have created in the first page to the second page..on clicking on the link, i called a js function and submits a form whose action tag is to the second page !! is there any other method ?? thanks raj
SCJP, SCWCD, SCBCD, Oracle Certified Professional (SQL n PL/SQL)
Rajeev Ravindran
Ranch Hand
Joined: Aug 27, 2002
Posts: 455
posted
0
sorry, i forgot to add this, I DONT WANT TO USE SESSION to pass the objects.. thanks raj
Bernard Fred
Greenhorn
Joined: Jul 17, 2003
Posts: 3
posted
0
I tink you can use de jsp tag FORWARD.
kalpana Kumar
Ranch Hand
Joined: Jul 03, 2003
Posts: 65
posted
0
Hi You can use forward(req,res). For Eg:- Say U want to pass a bean request.setAttribute("xxx",bean); RequestDispatcher rd;-this is for the particular jsp page to which control is to be transferred. Then use rd.forward(req,res); To get the reference of the bean u can either use <jsp:usebean> tag or (typecast)request.getAttribute("xxx"); Hope this helps..
pass an Object from one jsp page to another on form sumbit .... I DONT WANT TO USE SESSION to pass the objects
Then you are out of luck. A forward will not help you since that will just forward to the new JSP page within the context of the same request (in other words, no form submission). You can pass text data across the request context change via request parameters, but not objects. So except for tacking objects onto the session or servlet context, there's no practical way to preserve object instances. bear
Couldn't you store the object reference in request scope? request.setAttribute("xxx", yourObject); then do your forward, then on the target page <jsp:useBean id="xxx" type="YourObjectType" scope="request"/> to get access to it.
Ron Newman - SCJP 1.2 (100%, 7 August 2002)
Scott Duncan
Ranch Hand
Joined: Nov 01, 2002
Posts: 363
posted
0
You can pass text data across the request context change via request parameters, but not objects.
So request.setAttribute("whatever", Object) will not work. Try it using this in the calling JSP and request.getAttribute("whatever") in the called JSP and you will see that the object is null (at least in my experience this has been the case). If you are really determined you could Serialize the Object to file but the object you are trying to pass must be serializable (obviously).
No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Couldn't you store the object reference in request scope?
No. If a form submission is to happen, the first request context has long gone out of scope and a new request is created when the form is submitted. hth, bear
Ron Newman
Ranch Hand
Joined: Jun 06, 2002
Posts: 1056
posted
0
OK, sorry ... I obviously misunderstood the question.
Dorothy Finkel-Laverty
Ranch Hand
Joined: Nov 24, 2001
Posts: 51
posted
0
Couldn't you go simpler, and pass a serialization of object as a hidden field inside of the form? If worst comes to worst, you could pass the parameters as hidden text fields inside the form, and reconstruct the object again on the other side.
Scott Duncan
Ranch Hand
Joined: Nov 01, 2002
Posts: 363
posted
0
...pass a serialization of object as a hidden field inside of the form?
Huh? Please explain and give example.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.
subject: passing objects from one jsp to another !!