Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL SQL Question  RSS feed

 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Does anyone know a nice tutorial on how to provide the user with functionality dealing with multiple pages of a resultset..

I want them to see the <Prev Page> 1 2 3 4 5 6 7 8 9 10 <Next Page> but am not quite sure what the best approach is.

Thanks,
 
Rohit Bhagwat
Ranch Hand
Posts: 205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi dude..
You will have to code it yourself.

I had done coding for the same i.e I was able to display only 10 result /page and rest were in the form of links like next10 previous10 etc.

May be there might be some other technique to do this.

Regards
Rohit.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are looking at the wrong end of the spectrum for help. Rather than trying to figure out how to slice and dice a large resultset at the page level, this is something best handled as low-level as possible; preferably within the db itself.

Depending upon your db, you should be able to "slice and dice" large datasets by limiting the data returned. PostgreSQL for example uses the LIMIT and OFFSET clauses to cut up a large result set into a "paged" slice.

When handled at the DB level, this sort of functionality is almost trivial to code up.

What's your DB?
[ March 20, 2005: Message edited by: Bear Bibeault ]
 
Dave Brown
Ranch Hand
Posts: 301
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I see what you are saying.. I'm using mySQL.

I have a bean which has a function to return a resultset when the page loads. i was going to do a <c:forEach> on this resultset and use the maxrows approach but I see what you are saying, I could include the start & row limit in the query itself...

Rgds,

Dave.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, it's not only easier, but you avoid fetching excess data that you're not planning on displaying.

I'm pretty sure MySQL has a clause to limit the results, but I do not know the syntax off the top of my head.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!