aspose file tools*
The moose likes JSP and the fly likes sectioning a recordset using jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "sectioning a recordset using jsp" Watch "sectioning a recordset using jsp" New topic
Author

sectioning a recordset using jsp

Alfonso Harding
Ranch Hand

Joined: Feb 09, 2002
Posts: 35
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

Joined: Jan 10, 2002
Posts: 60041
    
  65

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60041
    
  65

P.S. Do search on 'paging' in this and related forums. This has been discussed quite a few times.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: sectioning a recordset using jsp
 
Similar Threads
Dynamic defining fields in Strtuts-config.
JSP and JDBC errors
Sorting the fields of a table
How to show only 10 entries in a jsp-page?
Maintain checked and unchecked in checkbox in pagination in display tag in struts