Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Pagination in jsp

 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 645
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi This is what i use for paging using JSTL,you may modify this to suit ur need


 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marshal
Posts: 67425
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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 ]
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, there are some sorry excuses for DB engines out there
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic