• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JSP Pagination for search results produced by search engine

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All! I have built a search engine for searching scientific documents. However, I am facing problem in pagination. My simple question is that all my results for a query are stored in 3d array:  Document   Score    Path. I want to display the results in multiple pages.
Many a topics discussed in this forum concern displaying results obtained from database. But my situation is different. I have retrieved all the results in a 3-d array. I just want to display them. Kindly help me on this.

Thanks!
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you fetch all the results? That's not going to scale well. Is it not possible for you to only fetch a page's worth of data at a time? That'd be most efficient as well as well as easier to deal with.
 
Amarnath Pathak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey! Bear Bibeault. Thanks! Actually that's not my concern. I will change it later on. I just want to know how to display already fetched results in different pages.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What would be best then (assuming you cannot pre-page the data) is to transform the data to a simple list (assuming that's what you will display) in the page controller rather than in the JSP itself. It's best to keep the JSPs as "dumb" as possible and do all the heavy lifting in Java code in the controllers.
 
Amarnath Pathak
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you please share a small piece of code? Actually I am stuck with it since long. I tried different possibilities but all in vain.
 
Saloon Keeper
Posts: 7582
176
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An easy approach would be to use a library like http://hazendaz.github.io/displaytag/ that creates the table display and also does the paging for you.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amarnath Pathak wrote:I will change it later on.


What I don't understand is all the time you are going to spend dealing with breaking up the large dataset when you are just going to have to throw it all away later when you change how the data gets fetched. It's clearly not something that's trivial, why not just do it the right way from the beginning?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic