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 JSP and the fly likes Pagination Problem 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 » JSP
Bookmark "Pagination Problem" Watch "Pagination Problem" New topic
Author

Pagination Problem

vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Hi

I had 4000+ records. I already worked on a kind of pagination where for every page number, request hits the database. I want to
modify the design .

First i want store 300 records in arraylist from database. i will show 25 records for each page number. so for each page click, request will not hit the database. It fetches records from arraylist. If arraylist get scarce of records then another 300 records should be fetched and then displayed.

Any one having ideas or suggestions, Please share....:)


Thanks
Vipul Kumar


Thanks
Vipul Kumar
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60759
    
  65

Sounds like a simple matter of book-keeping to me. You just need to keep track of what you have on hand and what you have already shown.

Give the code a try and post with specific problems you are having with it.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
vipul bondugula
Ranch Hand

Joined: Oct 14, 2010
Posts: 218
Thanks Bear


This is my Action Class code.



This is PaginationUtil class which supports ....







My Dao class:


In Dao code there is duplicate code. I mean class loading and getting connection. After completing the whole thing then i will modify them. Please check the logic...

I am getting ArrayIndexOutOfBoundsException.




my JSP page




I used scriptlets in my jsp code. Please ignore it. Anyway i will change the code. I am more concentrating on the pagination . If pagination get succeed then i will change the scriptlet code.

For the first time list is iterating fine. after first 300 records pagination , i will fetch next 300 records from database. fetched records iam storing them in arraylist from index 0 to 299. I am calculating fromIndex and toIndex (i.e. sublist for pagination) based on pageNumber. based on page number fromIndex and toIndex values are some 290 to 318. But in the arraylist index is from 0 to 300.

This clearly states that my design is missing something. Please correct this and share your ideas to generalize it.

Thanks,
Vipul Kumar.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Pagination Problem
 
Similar Threads
Pagination
Pagination
Pagination
Pagination