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

Struts Pagination

Senthilkumar Adaickalam

Joined: Nov 08, 2004
Posts: 14
Hi All,

I need to display the search results using struts and display tag. Following are the ways i have in mind to implement this but i would like to know the best optimal solution before start my development.

1) retreive the complete search results and store into the HttpSession object.
This may be a performance bottleneck if concurrent sessions opened.

2) retrieve the records from database on demand (let say 10 records per user hit).
Results in more number of costly database calls.

3) retreive the part from database and store into the HttpSession object, let say my search results in 1000 matching records and i will get the first 100 records from the database and put it in the HttpSession object. When the user clicks on page 11, i will query the database again and retreive another 100 recods and store/overwrite into HttpSession object.
I think this is the better approach among the above three.

Please let me know if you have any other better solution and how to implement.

Thanks and Regards,<br />Senthil
suj hande

Joined: Sep 07, 2007
Posts: 7
The 3rd approach is the most preferred .
Brent Sterling
Ranch Hand

Joined: Feb 08, 2006
Posts: 948
There is usually not a single "best" solution that fits all applications. Your #3 sounds good, but it is also the solution that requires the most work to implement, debug, document and maintain. If you are dealing with small sets of data you may want to not do any caching yourself and let the database handle that.

- Brent
Bhaskar Reddy
Ranch Hand

Joined: Dec 17, 2002
Posts: 52
Hey Senthil... H R U? do chk your yahoo mailbox for more qns !
I agree. Here's the link:
subject: Struts Pagination
It's not a secret anymore!