Reputation: 1481
I am developing a search engine in java.It works fine but all results are displayed in one page.How can I display results in separate pages like google. If I have 100 results then the results will be displayed in say 10 pages 10 results each. I am not using MySQL. My data is stored in files.
Upvotes: 1
Views: 137
Reputation: 13089
So you need to take the specified page number and use that to work out which result to display first in that page.
say your URL looked like this
www.yoursite.com?search=JSP&page=3
Then, you'd extract the search term and find the results. You'd also get the requested page and use it.
firstResultNum = page * resultsPerPage
for (i=firstResultNum; i<firstResultNum+resultsPerPage; i++)
{
displayCurSearchResult(i);
}
Upvotes: 1