File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Next & Previous buttons behaviour in my jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Next & Previous buttons behaviour in my jsp page" Watch "Next & Previous buttons behaviour in my jsp page" New topic
Author

Next & Previous buttons behaviour in my jsp page

Mamatha
Greenhorn

Joined: Jan 11, 2001
Posts: 5
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

------------------
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
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

Open Group Certified Distinguished IT Architect. Open Group Certified Master IT Architect. Sun Certified Architect (SCEA).
Ajith Kallambella
Sheriff

Joined: Mar 17, 2000
Posts: 5782
Your name "Mamatha" does not comply with the JavaRanch naming policy. Please choose one that meets the requirements.
Ajith
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Next & Previous buttons behaviour in my jsp page