Fetching records from database in chunks : <p>My java web application is retrieving a large dataset from the DB (DB2) and displaying the records on a webpage. 
Since the number of records is very large , the page takes a little time to load (about 15 secs)
To improve this , I want to implement pagination on the server side , ie fetch only 50 records at a time and show it on the page. 
Then when the user clicks on Next , the next 50 records are fetched and displayed.</p>

<p>I have already implemented this on the client side ie I am showing the data in chunks of 50  , <strong>but I am still fetching the entire data in one database call</strong>, due to which the page takes time to load.</p>

<p>How can I implement the pagination on the server side ie fetch only 50 records at a time ?</p>

<p>Thanks in advance.</p>
