aspose file tools*
The moose likes Servlets and the fly likes jsp page contents.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp page contents.." Watch "jsp page contents.." New topic
Author

jsp page contents..

Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
I have too many form elements in my jsp page. So i want to break this page into 2 pages, probably thinking of having a next and prev button on my first jsp page. Also i want to process all the form elements( ie both page 1 and 2 )and store the user entered info into database. Could anyone please suggest me how this can be done. Do i need to use <jsp:forward> tag for this to be done if i want to split my form elements into 2 pages.
Appreciate your help!
Thanks.
Dharmesh Shah
Greenhorn

Joined: Oct 01, 2001
Posts: 4
Hey Mandy,
I believe it should not be too difficult.
From the first page you may take the form data to your servlet/JSP and then populate your object(s) with the data received from the request object, now you can either put this object(s) in session or you may pass your object(s) with the response to the next jsp page using response.setAttribute(). In the latter case you will have to do request.getAttribute() and then response.setAttribute() in second JSP, but if u decide to put you objects in session then u can just get it back when u are ready to put them in the database, just make sure you specifically unset the session attribute after u insert your data in the database.
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Thanks. I will give it a try.
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
Hi Dharmesh,
I am thinking of storing this object in the session. You mentioned the other way to do this by passing along with the response object's setAttribute() method. Could you please let me know how this can be done with some sample code if you would, i am just curious to know and have never done this kind before.
Also i don't see any setAttribute() method of response object.
Appreciate your help!
Thanks.
Yongping Wang
Ranch Hand

Joined: May 15, 2001
Posts: 40
HI,
On the first page, using request.setAttribute("data1", Obj) { HttpServletRequest }to store your object and later on the second page, use request.getAttribute("data1") to dump the Obj. Hope it helps. ---Yongping

[This message has been edited by Yongping Wang (edited October 12, 2001).]
Mandy Smith
Ranch Hand

Joined: Jun 26, 2001
Posts: 62
I don't see any method called setAttribute for this response object in my documentation. Is there a method like this one.
response.setAttribute("data1", Obj)
Appreciate your help,
Thanks.
sanjay yermalkar
Greenhorn

Joined: Sep 19, 2001
Posts: 23
The attribute set in the request survives only for the lifetime of the request. When the second page gets displayed the request (which started when 1st page was submitted) dies. The values entered in the 1st page can be stored in hidden fields in the second page (if you'r not using the session).
[This message has been edited by sanjay yermalkar (edited October 12, 2001).]
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

Dharmesh,
What version of the specification has response.setAttribute?
Mandy,
You have a lot of options, among them, you can store the values in a bean, store them in a session object, or append them to the call to your next page.
For the experience, I would look at both beans and sessions (you would probably give the bean session scope, so you will need a bit of session knowledge). I think sticking them in the session is simpler unless you really have a ton of stuff then a more specialized bean would probably be better.
request.set/getAttribute is really not what you are looking for on this. You are not forwarding the request to the next page, you are going to have two seperate requests.
Andrew


!_I_Know_Kung_Fu_!
Terence Doyle
Ranch Hand

Joined: May 30, 2001
Posts: 328
HI,
Why not use one page that submits to itself?
Just check one of the second group of values to be null in an if statement and place the first form in the if part and the second form in the else part.
The second form will have a different action command so you can stay on that page with another if and process it there or go to some other page/bean/servlet.
This way the values all accumulate and as the JSP is already compiled and instantiated the jump from the if to the else is very fast.

Hope that helps,

------------------
Terry Doyle
Sun Certified Programmer for Java 2 Platform
[This message has been edited by Terence Doyle (edited October 12, 2001).]


Raising Flares debut album 'Ignition' out now

http://www.raisingflares.com

Terry Doyle <br />SCPJ 1.4 , SCWCD , SCMAD(Beta)
Dharmesh Shah
Greenhorn

Joined: Oct 01, 2001
Posts: 4
Correction it is request.setAttribute() and not response.setAttribute()
Mindi, if you havent pulled it yet, email me, I have similar code and would send you those files. Good Luck!
 
Don't get me started about those stupid light bulbs.
 
subject: jsp page contents..