This is a very simple way of doing it. Note, I did not clear the
cache. So the loaded table will permanently be loaded until user
session dies. Also if 1000 users load the page at the same time,
there'll be 1000 copies cached.
Let say your jsp page is named "listing.jsp"
listing.jsp
Request parameter
name: page
value: any number
description: Display page number x of the 120 records. Eg. 0 will
list records 1 to 10, 2=>11 to 20, and so on.
In listing.jsp
<%
synchronized (session) {
// if session attribute ArrayList "tablecache" is null
// then
// query db and add records to session attribute "recordcache"
// endif
// Note: consider storing in application scope to save memory
// Note: but need to release object once in a while.
}
ArrayList records = (ArrayList)session.getAttribute("tablecache");
int showPage = 0; // default
try {
// parse parameter "page"
// Set showPage to parsed value
} catch (NumberFormatException e){
// ignore
}
int lower = showPage * 10;
int upper = lower + 10;
// Check boundaries
// Display your records
for (int i=lower; i<upper; i++){
out.println(records.get(i));
}
// create navigation bar here
%>