I didn't look at your complete code, but your code looks very bad. Why are you doing all this business logic inside your JSP. Anyways it seems that you have used a column rownum in your database just for pagination. That is not required. Generally you can use a SQL query which limits the number of records and also decides the first record. For example in mySql I could use
select * from users limit 10, 20;
This statement will select 20 records starting from the 10th record...
In general if you are trying to do pagination then you can use either database related pagination or java related.
For java I can say if the data is less then you can hold all the data in a collection and add the simple next previous button to navigate(you need to call the java method everytime you click the previous/next button and the page will refresh using the data)
2. Second option is you can use the display tag library which is easy to use again if data is not too huge.
3. If you are using struts then you can use logic iterator tag which has capability to iterate for specified position.
Struts logic Iterator