• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Next & Previous buttons behaviour in my jsp page

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I'am displaying chunk(10 records) in a page from the database.Using the Next and Previous buttons on my page , I can retrieve 10 records at a time.The problem is explained below.
* Retrieve first 10 records(1-10)
* using the Next button get next set(10-20)
* Now using browser's back button goto previous page(page with the records 1-10)
* Now use Next button.Now the expected result is to get 10-20 records page, but i'am getting 20-30 records page.
*Also the Previous button behaves in the similar manner.How should I solve this problem.
Thanks
Mamatha

------------------
 
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that, the Servlet cannot detect user pressing the browser's back button. When the back button is pressed, the browser just displays the old page that is in the cache and no servlet communication takes place.
You can solve this problem by maintaining some kind of record number in the request which tells you upto what record is displayed. With each request ( next/prev ) you will add or subtract 10 from the record number and store it as an attribute on the request. This way you will not lose track of what you are displaying and what you should display when the request comes in.
Just a suggestion, there might be a better way to do this
Ajith
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your name "Mamatha" does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.
Ajith
 
reply
    Bookmark Topic Watch Topic
  • New Topic