wood burning stoves 2.0*
The moose likes Servlets and the fly likes Paging Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Paging" Watch "Paging" New topic
Author

Paging

novemberborn
Greenhorn

Joined: Oct 25, 2000
Posts: 2
Can we do paging of result retrieved from database (i.e only ten results should be shown on first page another ten on next page and so on). If yes then how ??
Frank Carver
Sheriff

Joined: Jan 07, 1999
Posts: 6920
This is a fairly standard question. There are several possible answers which depend on how much data you have to display, and where it comes from.
If you have a relatively small amount of data, which you can get before you display any pages, you can put it in an array (or an ArrayList, or Vector or other indexable data structure) and put that in the session with some indication of what you have displayed already. Each new page request can then show the next page of the data.
If you don't know how much data you have, or it is "expensive" to get it all at once, you really have to go back to the source for each new page. If your data is stored in a database, then you can generate slightly different SQL for each page to retrieve only the items you are interested in - the exact details depend on how your data is stored, of course.


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Paging
 
Similar Threads
Resultset Paging
Implementing a paging logic using stateful EJB
How to display 10 records per page
WA #1.....word association
Delay in JDBC ResultSet