Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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!
 
Author and ninkuma
Marshal
Posts: 66724
167
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
Author and ninkuma
Marshal
Posts: 66724
167
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: 4552
112
  • 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
Author and ninkuma
Marshal
Posts: 66724
167
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?
 
See ya later boys, I think I'm in love. Oh wait, she's just a tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!