File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes JSP Pagination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP Pagination" Watch "JSP Pagination" New topic
Author

JSP Pagination

gautam anand
Greenhorn

Joined: Jun 02, 2004
Posts: 22
Hi,

I have a JSP page in which i am displaying a number of values in simple HTML table using for loops. Since there are around 1000 entries i want to divide the exisiting page into multiple pages.I would appreciate if someone could provide an example of pagination or how it can be achieved.

Your help would be sincerely appreciated.

Thanks
Gautam
Gagan Gulati
Greenhorn

Joined: Jul 27, 2004
Posts: 7
Are you picking up these values from the database and then trying to show them ?
Or are you hard coding the values in the pages ?
Using DB, one easy way of doing it wud be to to show the 10/20/50 values on each page and do a next which grabs the next 50 values. You can write a simple Javabean method which does so or in the same JSP, you can submit the request with these paramters, and do getParameter() in the beginning of the page and retrieve values.

Let me know if u want to do it with Db...
I have worked quite a lot on it

-G
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

"gags gags",

We're pleased to have you here with us on the Ranch, but there are a few rules that need to be followed, and one is that proper names are required. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Alka Sharma
Greenhorn

Joined: Sep 02, 2002
Posts: 16
Gautam,
For achieving this, either you can fire a query to db everytime user clicks on next or previous button or fetch all of them in memory (in array or some other datastructure which maintains sequence) at one go as that would be faster.
But again that depends upon the no if records you are expecting in db which are going to be fetched.
You'll have to keep flags to check whether user has clicked on previous or next and manipulate data accordingly.
Also, you'll have to maintain counters to find out the starting no. and no of records displyed.
e.g if you are displaying 26-50 records then your starting counter will be 26, no of records displayed will be 25 and say if user clicked on next, u would know that you have to show 51-75 (26+25) - (50+25) records.

Hope this helps.
Thanks
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSP Pagination