In Action class, how to forward an ArrayList object to a JSP page using tag libraries.
Generally,in Action class,we create a session object .Then add an object to the session using session.setAttribute().Here i can add the array list object.Then forward the response to the jsp page.
Is there a way to do the same using tag libraires.
Joined: Dec 01, 2008
Ok. You need to understand that the tag libraries will come into picture only once your action has forwarded the control to the JSP. So even if we use tag libraries we MUST set the ArrayList either in the request scope or the session scope in the Action.
store data in calls any tag-libs
request/session if defined
Action -------------------> JSP --------------------> TAG LIB DEF (which will retrieve data from the request/session and process it in whichever form you need it).
So you see you must set the ArrayList in the session/request. The tag lib can help you format the data into whichever format you want (i.e. either a table or some other output mechanism).
However you do have an alternative which is to retrive/create the arraylist in the taglib itself. Then you wont have to actually set the ArrayList in the session.However that is something that is NOT recommended.