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
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>
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.
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