I have this problem. I have to show over 20000 records from the DB(database) in a jsp. I get 300 records at a time in the jsp and have a button to display the next 300 records. On clicking this button, the form is submitted and the next set of 300 is fetched from the DB To keep track of the set to be shown currently, I set an attribute in the session and increment it by one after every fetch. The problem is, if a user is on the 6th set and goes to the first one by pressing the browser back button, then, on clicking fetch more, he will get the 7th set rather than the 2nd one. If the user is using browser's back button, how would I track which set of record is he currently seeing?
The solution seems to be to not set the set number on the session but instead submit the set number when the user clicks the "fetch more" button. This could be done by saving the number in a hidden field.