0

I would like your help to guide me to the easiest way to do page pagination in my jsp.

My code is below which is listing the values in a generated table:

<% 
while(rs.next()){

%>  <a href="cir_view.jsp?cir_id=<%=rs.getString("cir_id")%>" Title="View" onClick="return popup(this, 'Report')">
<%=rs.getString("cir_id")%>
</a>
</span> </td>
<td width="39%" ><span style="font-size: 8pt"><%=rs.getString("institution_name")%></span></td>
<td  width="26%" align="left"><span style="font-size: 8pt"><%=rs.getString("requester")%></span></td>
<td  width="10%" align="left"><span style="font-size: 8pt">
<%=rs.getString("created_date")%></span></td>
<td  width="3%" align="left"><a href="cir_delete.jsp?cir_id=<%=rs.getString("cir_id")%>" class="ask" onclick="target='_blank';">
<IMG SRC="12.png" ALT="Delete" BORDER="0" ></a></td>
<td  width="3%" align="left"><a href="cir_update.jsp?cir_id=<%=rs.getString("cir_id")%>" onClick="return popup(this, 'Report')"><IMG SRC="28.png" ALT="Edit" BORDER="0"></a></td>

</div>
</tr>
<%

}

rs.close();

%> 
</td>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
maas
  • 361
  • 3
  • 7
  • 16
  • Dupe of [How to limit the HTML table records in each page](http://stackoverflow.com/questions/3389511/how-to-limit-the-html-table-records-in-each-page). Once again, don't use scriptlets. It's a maintenance pain and ends up to be pretty confusing for starters. PS: you should register your account. Now you have two, [here's your other](http://stackoverflow.com/users/397999/maas). – BalusC Aug 03 '10 at 11:41

1 Answers1

1

A good way to start would be:

  • move your code to a servlet
  • pass page number and page size parameters to a servlet
  • make your servlet return up to page_size rows starting from (page_number - 1) * page_size
Georgy Bolyuba
  • 8,355
  • 7
  • 29
  • 38
  • Just write the same code as you would do in a real Servlet class, but then mangled/cluttered/tight-coupled inside a JSP file. – BalusC Aug 03 '10 at 11:46