Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

JSP Pagination for search results produced by search engine  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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!
 
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
  • 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: 5330
143
  • Likes 1
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 67255
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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?
 
You can't expect to wield supreme executive power just because
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!