Hi,
I have question on mapping DB records to a
JSP using arraylist of actionform.
Currently I have situation in which I have to query database and display the obtained records on to the JSP. The number of DB records I get could vary from 20 to 20000.
So I am using array of value object to capture the obtained records and mapping them to array of actionform and putting this array of actionforms in session so that I can access this session object and display content on the JSP. To be more precise following is the overview of code
---------------------------------------------------------------------------
public ... Action(ActionForm form,...)
{
Arraylist afList=new ArrayList();
Arraylist volist = new ArrayList();
voList=getDBrecords();
afList=mapVOtoAF(voList); //this map function will return the array of actionforms
session.setAttribute("ActionArray",afList);
action.forward("success");
}
------------------------------------------------------------------------
This success action forward will take me to a JSP page where I will display content as
----------------------------------------------------------------
<%
java.util.ArrayList aList = (java.util.ArrayList)session.getAttribute("ActionArray");
java.util.Iterator Itr = aList.listIterator();
while(Itr.hasNext())
{
//create an instance of actionform and display the content
......
}
%>
----------------------------------------------------------------------------
So my question is am I doing the correct way or is there a better way to handling this situation. I have a concern with my code because if I get about 20000 records from DB I am afraid to put them in session because it might have performance impact.
Any suggestion or comments will be very helpful.
Thanks in advance.
Priya