Hi,
Here is the Example, of paging. It is just a single JSP file. If required move the logic to java file. Copy the below code and execute the JSP file to make sure every thing works fine. If any questions let me know..
<%@ page import="java.util.ArrayList,
java.util.Iterator,
java.util.List"%>
<%
ArrayList arrayList = null;
boolean check = true;
// session.removeAttribute("arrayList"

;
/* if you have the arrayList in the session Object avoid the DB Call
and get the ArrayList from the session Object
*/
if(null == session.getAttribute("arrayList"

)
{
/** need to get the ArrayList from the DB */
arrayList = new ArrayList();
arrayList.add("First"

;
for(int i=0; i<10; i++)
{
arrayList.add(i+""

;
}
arrayList.add("Last"

;
session.setAttribute("arrayList", arrayList);
}else{
arrayList = (ArrayList)session.getAttribute("arrayList"

;
}
int arrayListSize = arrayList.size();
// Number of Records that need to displayed per page
// make the increment value 5 and check it will display only 5 records per page
int increment = 2;
int fromIndex = 0;
int toIndex = increment;
String uri = request.getRequestURI();
String previous= "Previous";
String next = "Next";
List displayList = null;
if( null != request.getParameter("next"

)
{
fromIndex = Integer.parseInt(request.getParameter("next"

);
toIndex = increment + fromIndex;
if( toIndex+1 > arrayListSize)
{
toIndex = arrayListSize;
check = false;
}
if( fromIndex > arrayListSize)
fromIndex = 0;
}
if( null != request.getParameter("prev"

)
{
toIndex = Integer.parseInt(request.getParameter("prev"

);
fromIndex = toIndex - increment;
}
if(arrayListSize > 0)
displayList = arrayList.subList(fromIndex, toIndex);
if(fromIndex != 0)
previous = "<a href="+ uri +"?prev="+ fromIndex +"> Previous </a>";
if(toIndex != 0 && check)
next = "<a href="+ uri +"?next="+ toIndex +"> Next </a>";
out.println(arrayList);
out.println("<br>"

;
out.println(displayList);
out.println("<br>"

;
out.println(next);
out.println("<br>"

;
out.println(previous);
%>
Cheers,
Venu