Mentawai has a cool tag that will paginate any list of objects without requiring any effort from the developer. All you have to do is place the list with all objects in the action output and the paginator tag will pick up the correct elements to show on each page. You can see it in action here. Below is the JSP code:
<!-- "myList" is a list in the action output --> <mtw:paginator size="5" value="myList"> <mtw:isEmpty negate="true"> <h5>Results <mtw:resultFrom /> - <mtw:resultTo /> of <mtw:resultTotal /></h5> </mtw:isEmpty> <mtw:hasPrevious> <a href="/HelloPaginator.mtw?page=<mtw:out />"><b>Prev</b></a> </mtw:hasPrevious> <mtw:pageNumbers pagesToShow="3"> <mtw:isCurrPage> <mtw:out /> </mtw:isCurrPage> <mtw:isCurrPage negate="true"> <a href="/HelloPaginator.mtw?page=<mtw:out />"><mtw:out /></a> </mtw:isCurrPage> </mtw:pageNumbers> <mtw:hasNext> <a href="/HelloPaginator.mtw?page=<mtw:out />"><b>Next</b></a> </mtw:hasNext> <br/><br/> <font color="blue"> <mtw:loop> <mtw:out /><br/> </mtw:loop> </font> </mtw:paginator>