• Post Reply Bookmark Topic Watch Topic
  • New Topic

Display bean data on multiple pages?  RSS feed

 
Robert Stone
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out how to display data that my servlet returns on multiple pages. Here is the senario:

I have an HTML query form that is being used to submit search terms to a servlet which in turn passes the search terms to the appropriate method of the database search engine. The engine forms a query based on the terms and then queries the database. The data that is returned is put into customer objects which are added to an array list and forwarded to a display page. If the number of customer objects returned exceeds the room on the page I want to push the data onto a new page or something I don't want to just set the page to scroll because that is tacky. What is a good way to accomplish this task? Any suggestions would be greatly appreciated.

Thanks,

Robert
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's not the way you want to do it. If you are going to show the entire dataset across multiple pages, then you should only fetch one page of data at a time.

See the JSP FAQ for more details: PaginationOrPaging
 
Robert Stone
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't realy have a choice do I? I mean the user queries for customers with the name Joe Smith and the query returns 5000 names that is the dataset that I have to work with. How could I break it up?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you read the FAQ? The databases support the means to slice up the data into "pages" for you.
 
Robert Stone
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess I am just new to this and now that Oracle bought MySQL it's a documentation nightmare.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are alternatives to MySQL if you are not finding it to your tastes. You could also explore an alternative such as Hibernate which (for the most part) will abstract away database specifics.

If you are already using MySQL successfully, then it's just a matter of doing a little math and adding a LIMIT clause to your queries. mysql limit clause
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!