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 Pagination in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Pagination in jsp" Watch "Pagination in jsp" New topic
Author

Pagination in jsp

Neela Sathesh
Ranch Hand

Joined: Jan 19, 2004
Posts: 50
hi friends,

I am displaying currently a 100 records in my table which are fetched from the databse.But i need to display only first 10 records in the table and there will be a next button.after clicking on that next 10 records have to be displayed.
Similarly there will be a previous button ,on clicking that previous 10 records have to be displayed.

Can u help me on that.

With regards,
Neela


With regards,<br />Neela.N
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 614
Hi This is what i use for paging using JSTL,you may modify this to suit ur need




All desirable things in life are either illegal, banned, expensive or married to someone else !!!
Daniel Rhoades
Ranch Hand

Joined: Jun 30, 2004
Posts: 186
Yes paging is easy when using a database, simply manipulate the LIMIT clause for each page, i.e.

items_per_page = 10;
total_pages = (SELECT count(*) FROM table) / items_per_page;

this_page_content = SELECT a_column FROM table LIMIT 1 to 10;
[ March 11, 2005: Message edited by: Daniel Rhoades ]

Drinking more tea is the key...
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60990
    
  65

simply manipulate the LIMIT clause


Assuming that the DB supports such a clause. Not all do. PostreSQL, for example, has the LIMIT and OFFSET clauses that make dataset paging almost trivial.
[ March 11, 2005: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Daniel Rhoades
Ranch Hand

Joined: Jun 30, 2004
Posts: 186
Yes, there are some sorry excuses for DB engines out there
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pagination in jsp