File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Next page Previous page 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 "Next page Previous page" Watch "Next page Previous page" New topic
Author

Next page Previous page

J Craig
Greenhorn

Joined: May 04, 2004
Posts: 15
Given a result set or collection can anyone help in implementing a next page previous page functionality.
Should be able to list a set amount of records that will be viewed and if you get real fancy indicate how many pages are present basically the same as this site uses
Chris Baron
Ranch Hand

Joined: Mar 21, 2003
Posts: 1049
Hi Jay,
try LIMIT with your DB:

should return 5 rows: 11 to 15.

returns a rowcount of your table.
If you have a variable configuring the amount of listed items p. page
and one containing the actual pointer, e.g.

the next-link would be then:

and your SQL-Statement was something like this


...some untested hints to get started.
cb
Sloan Bowman
Ranch Hand

Joined: Jan 21, 2003
Posts: 107
As previously stated you can one of two things. First off the easiest would be to simply supply the offset option in your sql code and create a new Collection each time the page is loaded and pass that to the view. Or you can create a Collection and cache it to memory and only pull the specified number of objects from the Collection. If you need examples let me know.
michael yue
Ranch Hand

Joined: Nov 20, 2003
Posts: 204
Some database does not support the LIMIT statement. How to tackle this? I come to know that db2 is one of db that does not support this. The closest thing to a LIMIT function is FETCH is db2. Maybe using FETCH with ORDER and WHERE will produce the results but i dont think its feasible.

Using caching I think will also eat up memory especially if the resultset is large in the region of thousands. So have to fully load up the thousands of records in to memory before finally displaying the first page.

Using cache rowset is also another way but i found out some webserver does not support this method such as Websphere.

So I was wondering is there a universal way to do this that can run on any webserver and database and on the same time does not take too much of a time to process.

Thanks
Brahim Bakayoko
Ranch Hand

Joined: Aug 29, 2003
Posts: 155
see my post here: http://www.coderanch.com/t/284573/JSP/java/Displaying-large-ResultSet-multiple-HTML


SCJP, SCWCD, SCBCD, IBM CSD WebSphere v5, <br />A+, MCP 2000 and 2000 server, CST, and few incompleted certification tracks.<br /> <br />Ivory Coast<br /> <br />Analyze your web Request/Response @ <a href="http://webtools.servehttp.com" target="_blank" rel="nofollow">http://webtools.servehttp.com</a> down for a while...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Next page Previous page
 
Similar Threads
Next & Previous buttons behaviour in my jsp page
displaytag should show only previous and next
Dynamic next/previous link
How do I maintain the state of checkboxes across page?
what is page Nation