i want to create in the bottom of the page the option to move from one page to another like this " page: 1,2,3,4,5"
someone know how can i create the " page: 1,2,3,4,5" ?
http://mrbool.com/how-to-handle-pagination-using-jsp-pages/28345 and if you want to do client side pagination using following link
You need to know the number of records you want to display on each page. And divide the total number of records in the list by that number to get the page numbers. Note that you will need to add 1 to that result if the remainder of the division is not 0. You will then need to know the last record of each page that you will pass on to the next page. This last record should be a unique column value(number preferably). Note that the column should be sorted.
i have coupns list . i want to create in the bottom page number . in every page i define to have 3 coupon Maximum."every page" i mean it's the same page !!
i just want to change the index from where to start to print the coupons.
i try to create static variable
<%! static int indicateFromWhereToStartPrint = 0; %>
and the pages numbers i create like this
<a href="#" onclick="goToPage(2)">2</a>
i did this for every page .
in the function i increased if necessary the indicateFromWhereToStartPrint , the problem is the variable is incress even when i do reresh to the page
It is very difficult to guess the logic you use in your jsp page. When you have divided the number of records in your coupns list by 3, just go through the list and record the indexes at position 1, 4, 7... You will then pass these indexes like <a href="yourjsppage.jsp?index=<%= index%>">1</a> <a href="yourjsppage.jsp?index=<%= index%>">2</a>...
and you build your query as follows:
"select * from yourtable where index>="+(request.getParameter("index")==nul)?index:request.getParameter("index")+" order by index asc limit 3"
Hope i will be understood.
After I tried a few things and I failed I decided to try a session, I guess it will work. Anyway thanks helpers.
I think if you had followed Bear's advice or mine, together we could have come out with something that works. But good luck in your new endeavor. I hope you will get a right solution.
Bear Bibeault wrote:You should not any have variables or any other code in the JSP page. Perform the data handling in the servlet controller. Keep track of what "page" you are on using a hidden variable in the form.
1)i have a list that come from the servlet ,i need to print this list how can i do that if not using inside the jsp ?
2)"Keep track of what "page" you are on using a hidden variable in the form" i do not know which way you go
my solution is to save in session the index and For example if the user click the page 2,i send to servlet the number 2 and he will change the value that i store in session that track the index . and the user
will be in the same page but now the page print the coupons from the new index .Is this idea right ?