- Posted by: Shoaib Akhtar
- Posted on: June 01 2003 14:58 EDT
I have a solution for showing large result sets. This solution is when you r using jsp to show the result of large query, and u want to show the results 5 at a time and with Next & Previous buttons, u can also give page numbers in the end too i.e 1 2 3 4 etc.
What i actually did is that whenever somebody ask for that result set taht is large and for that i want o show 5 records per page, i forward it to a servlet which actually execute the query and store the result set in cachedrowset and also store the reference of this cachedrowset in the Http session. It then dispatch the control to a JSP with first time a variable appeneded to it named offset e.g showresult.jsp?offset=0 now i place the cursor to offset + 1 i.e 1 for the first time. Then show say 5 result onward from the offset in the end the link of Next sets the value of offset to offset+5 and previous to offset-5 and i actually used cahedrowset.absolute(offset)
and then if(cachedrowset !=Null)
While(int i = 0; i<5;i++)
//process the results
} // end of if
And for calculating the page number i have the size method
of cached row set that size/5 + 1 is the numbert of pages for the result set and for each link there is +5.
Looking forward to disscuss this solution with u ppl.
775 at nu dot edu.pk
- This the solution for showing large result set ( i.e Paging) by michael yang on June 02 2003 02:56 EDT
- This the solution for showing large result set ( i.e Paging) by Kiran Kumar on June 02 2003 14:11 EDT
- This the solution for showing large result set ( i.e Paging) by Shoaib Akhtar on June 02 2003 15:01 EDT
- This the solution for showing large result set ( i.e Paging) by Sean Sullivan on July 30 2004 18:34 EDT
can you give me a example for more detail.
You might also want to check out the ValueListHandler Pattern
> You might also want to check out the ValueListHandler Pattern
Thanks for information, i know the pattern u described but i think that my solution is much better if u want performance as in ValueListHandler u have to create object for the result set and then pass it say 5 at a time. This object creation process takes a much longer time than to cachedrowset approach and also if records returned are more than 5,000 then often the application server runs out of memory. And If u regard Richard Monson Heifel then he also advised to use cachedrowset.
Also, look at http://valuelist.sourceforge.net
Paging in J2EE: Manage Large Result Sets Efficiently