File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Problem With Pagination Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Problem With Pagination" Watch "Problem With Pagination" New topic

Problem With Pagination

A.S. HariLal
Ranch Hand

Joined: Oct 24, 2007
Posts: 31
Hai Dear Friends,
I did my pagination with the help of pager tag lib. It's working well.
But I noticed that it fetch all the data's from table for each iteration.( Iteration means when I select Next or Previous link)But it display the data's based on the offset. I hope It's not good method. If I have a database containing 1000 items and for each iteration , If it takes all the data's .....the syutem will go I hope there will be an alternative method or a solution to solve if any one experience such like problems and solve it.....kindly help me......
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
There are more advanced things you can do with the pager tablib, but with a basic implementation your action will load all the records from the database and the taglib will "throw away" all the records except the ones needed for the current page. This seems very wasteful, but I have found this to be acceptable in most cases. One simple optimization is to store the results on the session so you don't have to query the database each time. This solution does not work well for very large datasets or sites with lots of users.

- Brent
xu yuanzhi

Joined: Nov 20, 2007
Posts: 6
You will calculate which records to be displayed in page with page number,order(desc or asc) and how many records is displayed in one page. As said above, it may be wastful
A.S. HariLal
Ranch Hand

Joined: Oct 24, 2007
Posts: 31
Thank you For the answers........
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Please check your private messages before posting to the ranch again.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Problem With Pagination
It's not a secret anymore!