Maybe you could describe the situation in a bit more detail. Are you trying to submit data from the user's browser? An action forwards on to a jsp page which renders html. This is all done on the server side. The client side browser just knows about the rendered html.
posted 12 years ago
Brent, I have a ArrayList that is returned from my Dao. I pass this ArrayList to my JSP using request.setAttribute. In my JSP i iterate and display the values. I now need to pass this ArrayList again to another action class. How can I do it other than setting the ArrayList in session? What is the best way?
If you have a form submit which goes to an action class you can directly use request.setAttribute(Arraylist,"name"); ...I thnk The request object is implicit to the jsp page .. If you have a URL then I thnk only a session/application scope will help .
The best way to do this is to put the ArrayList in your ActionForm bean and then use indexed properties to display them. If you use this technique, Struts will automatically populate the array list for you when the form is submitted.
There is something you have to be aware of, though. You will either have to put your ActionForm in session scope, or provide some special handling if you put it in request scope. Since an ActionForm that is in request scope has to be rebuilt from scratch after the form is submitted, you must provide "lazy initialization" methods to rebuild the ArrayList. This link provides some good information on how to do this.