| Author |
best practice for dividing search results into pages
|
Edmund Castermund
Ranch Hand
Joined: May 09, 2007
Posts: 77
|
|
Hi,
I have an app that goes into a db via jdbc to grab a list of objects and then a servlet presents them in the form of a table.
The app shows the search results in pages....the first 25 results, then click next, 26-50 and so on. Currently, every time the user clicks the link for the next page, a new search is generated returning the entire result set. I realize this is a terrible way to do it. My current plan is to send a page num to the function that calls the sql statement and adjust it to get the results I want...but I was wondering, since this is a ubiquitous scenario, what is the best practice for this?
Also, currently the app gets a list of objects and pulls all the data for those objects whether they are used or not. In terms of scalable db searching code, what is the best practice for this? any good books re: java -> db you can recommend?
bp
|
 |
Edmund Castermund
Ranch Hand
Joined: May 09, 2007
Posts: 77
|
|
ok,
answering my own question here. Came across this tutorial:
http://theopentutorials.com/examples/java-ee/jsp/pagination-in-servlet-and-jsp/
This will make it pretty easy to chunk up the search results:
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56232
|
|
There's info on this in the JspFaq.
And yes, making the database do the work is the right approach.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Wendy Gibbons
Bartender
Joined: Oct 21, 2008
Posts: 1098
|
|
limit is db dependant, This is mysql isn't it?
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56232
|
|
|
Yes, it is DB-dspecific syntax. Using JPA or Hibernate eliminates the dependence on a particular SQL dialect.
|
 |
Bill Clar
Ranch Hand
Joined: Sep 21, 2006
Posts: 104
|
|
I was oblivious to the fact that Informix had such a feature:
Time to do some refactoring.
|
 |
 |
|
|
subject: best practice for dividing search results into pages
|
|
|