Assuming your search is normal database result set recieved from some SQL query ( search is not Lucene/Sor based)
After getting result set in your
java code, find the size of result set (for example - you get 88 search result items).
Now your page can only show 20 records per page.
Total number of page becomes 88/20 = 5 (with 18 search items on 5th page)
in your
jsp, you can set page numbers as shown below
Page numbers
href="/baadal/list/cloud/page/CloudServlet?pageNumber=1"> 1<
href="/baadal/list/cloud/page/CloudServlet?pageNumber=2"> 2<
href="/baadal/list/cloud/page/CloudServlet?pageNumber=3"> 3<
href="/baadal/list/cloud/page/CloudServlet?pageNumber=4"> 4<
href="/baadal/list/cloud/page/CloudServlet?pageNumber=5"> 5<
for example - when user clicks on page number 2 then you need to pick up the search items from 21 to 40 and display it.
To achieve this, you can retrieve value of pageNumber in your Cloud Servlet. And simply calculate lower and upper limit of search items.
do [(pageNumber-1)*20 +1] to get lower limit (which will be (2-1)*20 +1 = 21).
do [(pageNumber)*20] to get upper limit (which will be (2)*20 = 40). If upper limit exceeds total number of search items (88 in this example) then assign upper limit as total number of search items (88).
based on upper and lower limit, you can now show search resut from 21 to 40 when user clicks on page number 2.
Similiar approach can be applied for rest of pages.
~ abhay
Oracle certified JPA Developer (1Z0-898),Oracle certified Java 8 Programmer I (1Z0-808), Oracle Java Web Service Developer (1z0-897), Oracle certified Java 7 Programmer, SCJA 1.0, SCJP 5.0, SCWCD 5.0, Oracle SQL Fundamentals I, CIW Certified Ecommerce specialist