Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

paging help

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34680
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Shan,
What are you getting?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic