Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

paging in servlets

 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the middle of implementing Catalog Page - following Marty Hall book -well the sample codes only use static Array.

My catalog data is in table.

is it good idea to load all records in catalog object (ArrayList)? they are around 100 at the moment and growing.

is there another/better approach? could someone show me how to implement paging (say 20 item per page) in Servlets or should handle by JSP? how? is there any online sample/resources?

thanks all
tony
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tony,

There is a datastructure called Cached Rowset in Java which can be used to get the data in a tabular form in one call to the database and then u can read the data records 10 rows at a time from that. This is also called disconnected rowset as it doesn't fires a connection every time next set of records are fetched.

I think this can be the suitable option for you if your data doesn't get updated every time.

Thanks,
Rahul Juneja
 
Anthony Karta
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rahul! I didn't realize Java has Cached Rowset. But how to implement it...

do I need to create Cached Rowset for every session? or put it in init() method in Servlet or import the data class in JSP page?

if Rowset is disconnected then how I can check the stock of items?

do you have some sample codes or somewhere on internet?

thanks again
tony
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic