show 10 records per page

Hello,
i am writing a servlet to retreive records from a table in db2 database and show it them the browser. But i want to show only 10 records per page and there would be a next button on every page which would take to the next 10 records.
Pl tell me how do i acheive this.

Thanks
Rama
ramakrishna030399Asked:
Who is Participating?
 
memingConnect With a Mentor Commented:
1) Create RecordSet using user query
2) Iterate through the first 10 (0..9) records and return to client a 10 row table in HTML. Also include in HTML with previous and next links such as this: <a name=next href="/servlet/Scroller?pageNum=1">
3) Before returning the first HTML page to client, save RecordSet in a static variable of the current class. (more later)
4) Once client clicks "next" link on the first HTML page, get the RecordSet object from the static variable and get the pageNum=1. Since 1*10=10, repeat step 2 starting from record number 11. This new HTMl should include <a name=prev href="/servlet/Scroller?pageNum=0"><a name=next href="/servlet/Scroller?pageNum=2">
5) repeat step 2 to 4 and skip 3 since you want to reuse the RecordSet.

As you might see here, this program will only work correctly for one client. If there are more than one concurrent client, saving RecordSet in a static variable may cause problem, since different users might wnat different queries/recordsets.

This is where database connection pool is needed. This's a way of managing multiple database connections or recordsets for multiple concurent users. You can implment it yoursleves by using hashtable with user session ids(watch out for synchronization problems), or you can find a premade one.  Most application servers support it.

0
 
shaveriCommented:
0
 
Ravindra76Commented:

Hi Ramakrishna,

 Your previous questions

 add number of days  and
inserting double int string are solved?

 or

still are you facing problems?

Best of luck
0
 
ramakrishna030399Author Commented:
ya ravindra...
those problems were solved,..thanx a lot...
ragards
rama
0
 
Ravindra76Commented:
Hi ramakrishna,

If your problems are solved, grade them.
If you don't grade them, they will automatically graded ( C graee) by EE
after some time.

Thank you
0
All Courses

From novice to tech pro — start learning today.