Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sectioning a recordset using jsp

 
Alfonso Harding
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a database with over 1000 entries. I would like to know how can I break up the entries
so I can display a 100 per page as supposed to displaying the whole record set one page? So if a user gets pulls up the database the first page will display 1-100 and if an icon or link is clicked it will go to 101-200 etc. How can I do this using jsp?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A JSP isn't exactly the best place to do this type of processing. You should consider filtering down your dataset long before it gets sent to the page.
Depending upon which DB you are using, there may be facilities that make it easy to do this closer to the back end. For example PostgreSQL has LIMIT and OFFSET clauses that you can place on a query that make paging through large datasets almost trivial.
If your database lacks such capabilites you can: (a) switch to one that does, (b) pare down the data sent to the JSP in a controller servlet, (c) pare down the data in a bean that abstracts the query, (d) something else that I haven't thought of yet. (In order of my own preference).
Handling this type of complex logic directly on a JSP is the last thing you want to do.
hth,
bear
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64972
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
P.S. Do search on 'paging' in this and related forums. This has been discussed quite a few times.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic