Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Servlet to Display a Certain Number of Returns per Page

Status
Not open for further replies.

vvicin01

Programmer
Aug 14, 2001
21
0
0
US
I've created a servlet that simply queries a database and displays the result set. However, because the data that is returned is so lengthy, I would like to only display 25 or so records a page and then allow the user to click a continue button to display the next set of 25. Does anyone know how to do this? Thanks
 
It depends on the database your are using.
If you were using MySQL it has functions to do that.

There is a generic form passing the current index to the next page, for example 26, then in that page move the resultset until the 26 row and display the next 25 rows.
The link for the back and next pages would have the indexes 1 and 51.

These form of getting data is not very good because your getting the full recordset every time. You could improve the performace writing to sotered procedures in order to get the data grather o lesser that the index received. And limiting the resultset size, your dbms must have an order to do so.
 
Hi,
Have a look at this page

It has JSP tags that will do the index for you you just provide a list of all the results you want in the index. You have to run the query every time the page refreshes though from what i can see. Let me know if you use this a find a way to avoid doing the wuery each time.

Iam trying to do a similair thing. I have written the code to produce the index of the results but i do not want to do the query every time the page loads. I have copied the result set into a vector of my own row result objects and now i want to find someway to cache that vector so when the page refreshes with the new index it can still access that vector. Is there an efficient way to do this?

I could really do with some help here as this has be troubling me for days now.


Cheers
Alan
 
Alan,

Try caching the Vector object in the HttpSession object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top