aspose file tools*
The moose likes JSP and the fly likes data persistence across many JSP's Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "data persistence across many JSP Watch "data persistence across many JSP New topic
Author

data persistence across many JSP's

kiran giriya
Greenhorn

Joined: Nov 28, 2001
Posts: 5
Hello
i m having 5 jsp's ,each jsp containing some 10 to 15 form fields.I need to have the data entered by the user in each Jsp's to be available in all other jsp's and so that in my final jsp i should have all the form values of 5 jsp's.One way it can be done is passing as hidden parameters to all jsp's and fetching by request.getParameter or using jsp:forward and param tags.But i feel this is cumbersome.What are the other all possible ways.Please let me know all the other way of doing.Thanks in advance.
regards
kiran
Shawn Bayern
Author
Ranch Hand

Joined: May 06, 2002
Posts: 160
Originally posted by kiran giriya:
Hello
i m having 5 jsp's ,each jsp containing some 10 to 15 form fields.I need to have the data entered by the user in each Jsp's to be available in all other jsp's and so that in my final jsp i should have all the form values of 5 jsp's.One way it can be done is passing as hidden parameters to all jsp's and fetching by request.getParameter or using jsp:forward and param tags.But i feel this is cumbersome.What are the other all possible ways.Please let me know all the other way of doing.Thanks in advance.
regards
kiran

Typically, the easiest way to share data among JSP pages is to use the 'session' scope (corresponding to an HttpSession object). If you use scriptlets, you can write

to set information and

With JSTL (the JSP Standard Tag Library), you can write

and retrieve info from the session using expressions like


Shawn Bayern<br />"JSTL in Action" <a href="http://www.jstlbook.com" target="_blank" rel="nofollow">http://www.jstlbook.com</a>
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
kiran
If you've got that many fields to pass you might want to create an object to hold them (if it is applicable) and then use Shawn's suggestion of the Session and then you'd just have to pass one object not all of the fields. Of course you'll still have to set all of the values in the object.
That would be a perfect place for a bean just set up a bean with the same member names as the form fields and the you can use the setProperties tag to set them all at once. Then create a method in the bean to return one of those object to store in the session.


Dave
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Hi guys..
Well, I thought about using a bean, just as dave commented. but, what I'd do is in every JSP page I'd type

so I will have access to all information in every page... Is that OK??
correct me if I'm wrong.
thanks


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Just be aware that the useBean tag will create an instance of the bean using the default constructor if one hasn't already been created and set into the session with that name.
hth,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: data persistence across many JSP's