JSP Question
Hey guys,
I hope you can help me to come out from this situation...I have a huge database and want to display 20 records on each page...nothing is coming up in my mind...can you please give me the logic how I can place page numbers and next, prev button in my JSP..... any idea or example will be appreciated....
thanks a lot..
Vic
[356 byte] By [
vishu007a] at [2007-10-2 13:12:38]

For the first time when u get the records from the database, count the total number of records, divide it by 20 and return the number,say n. Also get the first 20 records. In the page display the first 20 records and also display the page numbers from 1...n. Now suppose u click on 5, then get the records from (5-1)*20+1 to 5*20. Also such logic can be applied to previous and next button.
getting n pages from the database efficiently might be the OP's problem since the database is huge.
There are two basic solutions that I know of:
1) when using MySQL or PostrgreSQL, use the LIMIT SQL command
2) in all other cases, limit the size of your resultset with Statement.setMaxRows().