This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes how to paging database results in different html pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Servlets
Bookmark "how to paging database results in different html pages" Watch "how to paging database results in different html pages" New topic

how to paging database results in different html pages

juan ramon

Joined: Jan 21, 2002
Posts: 2
Someone can give me some examples code of how to add to my database result page the option of paging the results, I mean to put the next, previous navigation options.
My database is a postgres.
Rick Salsa
Ranch Hand

Joined: Jul 17, 2001
Posts: 173
Hi juan,
Take a look at sun's site.
[ January 21, 2002: Message edited by: rick salsa ]
shai koren
Ranch Hand

Joined: Nov 04, 2001
Posts: 48
If you dont use EJBs you could also add the data from the DB to a list of custome objects and store it in the session. then the links on the page will include params that will indicate the current index and weather it's "next" or "back" which according to you will either add or take the number_per_page (your variable in the servlet/jsp) to/from the index. you just need to watch yourself with the rules for "back" and "next" so that you dont actualy try to get items from the list with wrong index (like -n or more then the list actually has).
Of course if you work with ejbs forget about this one.

Shai koren<br />SCJP2 <br />SCEA (well yea only part 1 so far)
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

I disagree with putting search results on the session, but I disagree with putting anything on the session, in general
The best answer to your question is "it depends on the context".
This topic turns up very often and there is some very good material available in this and other forums and I'm not going to try to reproduce it here (I'm bound to get it wrong).
If you search the Servlet, JSP and JDBC forums you will find some excellent discussions.
I agree. Here's the link:
subject: how to paging database results in different html pages
It's not a secret anymore!