posted 23 years ago
This is a fairly standard question. There are several possible answers which depend on how much data you have to display, and where it comes from.
If you have a relatively small amount of data, which you can get before you display any pages, you can put it in an array (or an ArrayList, or Vector or other indexable data structure) and put that in the session with some indication of what you have displayed already. Each new page request can then show the next page of the data.
If you don't know how much data you have, or it is "expensive" to get it all at once, you really have to go back to the source for each new page. If your data is stored in a database, then you can generate slightly different SQL for each page to retrieve only the items you are interested in - the exact details depend on how your data is stored, of course.