This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes Spliting records per 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 "Spliting records per page" Watch "Spliting records per page" New topic
Author

Spliting records per page

shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Hi Guys

I am trying to handle 100 of records and want to split them into pages (so only 50 records per page with back/forward links). Im not entirely sure how I should code this. I was thinking of placing all records into a list and then simply use get to call the records. What do you guys think?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

See the JSP FAQ entry on paging.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
shaf maff
Ranch Hand

Joined: Sep 07, 2008
Posts: 180
Thanks, a good read. But how should code it whilst storing the data in a session ? I am thinking of getting all the records and storing them into a session and then paginating, but that isn't efficient as the servlet might need to load 1000s of records so it would be better to load only the records the user requests.. So an alternative method is checking the session for the requested records, then the DB(if request data not found in session). Does that sound like a good solution?

[ September 29, 2008: Message edited by: shaf maff ]
[ September 29, 2008: Message edited by: shaf maff ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

If you want to balance memory load with DB access, caching is a good idea. Just be sure that it's fairly configurable so that you can easily adjust it to suit the conditions.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Spliting records per page
 
Similar Threads
Displaying resultset in many pages
read a text file
browsing the records
retrieving thousand of rows from DB2 database
want to display results page by page