This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes JSP and the fly likes paging help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSP
Bookmark "paging help" Watch "paging help" New topic
Author

paging help

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
I have 100 records and I display 10 per page. So I get 10 links on my page.
What I want to do is display 5 links and a next button. When the user clicks on the 5th link it should display the next 5 links.

For eg (looks like this now)
1 2 3 4 5 6 7 8 9 10


I need like
1 2 3 4 5 next>>

if I click on 1 2 3 4 link it should display the same as above.. Only
if clicked on 5th link i need to display

<<prev 6 7 8 9 10 next>>

below is the for loop I tried but I am not getting the desired effect.

if(currpage!=0)
out.println("<a href = 'empCases.jsp?page="+ (page1-1) + "'>" + "[prev]" + "</a>");

for (int i= currpage, j=0 ;(i<numPages && j< 5 ); j++,i++){
out.println("<a href = 'empCases.jsp?page="+ i + "'>" + (i + 1) + "</a>");

if(currpage<(numPages-1))
out.println("<a href = 'empCases.jsp?page="+ (page1+1) + "'>" + "[Next]" + "</a>");
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32481
    
214

Shan,
What are you getting?


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: paging help
 
It's not a secret anymore!