Presently working on a search and listing page. The search may retrieve an ArrayList of data but on the list page, oni a limited 10 lists of data will be shown. Does anyone noe how do i keep the rest of the data so that when user click "next" list of data, i can display the next few data in the listing page? have used set and get attribute to display the 1st set of results but when i use get attribute again... it return null.
thks in advance...
if you are using just jsp/servlets, you will need to put the arrayList into HttpSession object.
if you are using JSF, you can use managed-beans with session scope.
or if using some sort of ORM will be similar as well.
or if going stateless, and if the list is small,
you can stringfy (either the data, or html representation) the data in a hidden input field so that you can pass it from one page to another.
or a ghetto way is to keep track of the page you are on
in a hidden input field, and every time they switch a page, take a hit on the db w/ a sql query that needs the page to be passed in.
The ArrayList data that you store in request is stored only for the request Scope. To use the same Object on multiple pages you should store the Object in session.
This object stays as along the session is valid. If this Object is very large then you should consider clearing this object after use.