I have a JSP which shows a list using Logic:iterate tag. Now I want it to display only 10 records at a time and subsequent records should be shown when the user asks for next 10 records.
Any idea how to do this????
get the records and store them in a collection. Store the collection in session. take the first 10 records as a subset and pass it to the iterate tag. use the hidden field to keep the last record number in the jsp. So when you first see the jsp the first 10 records will be shown and when user clicks for next records send the hidden field value to the server and take next 10 records as subset and pass it to iterate tag. This is how you can do this. but if you have thousands of records storing them in the session is not recommended. you can pull them directly from the database.
That isn't so bad, but you have to keep the numbers in your mind. A 100 records in the session is still a lot when there are 200 sessions. You should research pagination to see common strategies to work with subsets of data without having to tank it all into memory.
The better way is to do pagination on the database side if you have more number of records. The following is the way to do pagination in MSSql.
select *, (select count(*) from pagination) as totalResults from pagination where RowNo between 11 and 20 order by rowNo
We are trying to pull the results from pagination table in the above. The table could be any table according to ur requirement.
you need to maintain the max row you pulled as hidden field. Please find something like this for your database.
but it is highly DBMS and data-set specific. I've done pagination in sets of millions of records by adding a batch sequence number and using an SQL between and a proper index to eat through it 10000 at a time - but that only works when you actually have a set of data that can be defined in batches.
Hi I don't really understood what you are saying but this is something interesting. if you pull 10000 records at a time where do u store them? I am not sure whether i have correctly understood but interested in this solution. If you don't mind can you explain it with a simple example.
Edited by: Muralidhar on Mar 29, 2013 10:30 PM