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
posted
0
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
posted
0
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
posted
0
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
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