Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pagewise Results

 
ch praveen
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I have got a lot of records to display. Instead of displaying them all at once I want to display 20 records per page. Please suggest me way to accomplish this and if possible provide snippet regarding this. Thanks in advance.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Linux Postgres Database Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by ch praveen:
I want to display 20 records per page.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That approach will obviously not work in the web environment. But the original poster wasn't very clear on that.
 
ch praveen
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
Thanks for ur responses. But It didn't answered my question. Is there any command in Java that accomplishes displaying only a certain portion of ResultSet [0-20,20-40 records and so on]? Whether I must write my own coding to skip the unnecessary records and to reach the necessary records range? JavaRanch displayed pagenumbers such as 1>>2>>3>>..... and showed only certain messages(posts)in a webpage. I want similar approach in displaying ResultSet contents in my application. Can JavaRanch people help me in accomplishing this.
 
Pawan Ramchandani
Ranch Hand
Posts: 78
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using below mention code to solve that kind of problem in my project and it's working properly
TRY TO UNDERSTAND THIS CODE
__________________________________
First declare one integer:-
int start=0;
__________________________________
when you print the user values just increment the value of this int:-
out.println("<tr><td>"+(start+(noOfComp++))+"</td><td>"+job+"</td></tr>
__________________________________
put this code with result set:-
for(int i=0;i<start;i++) rs.next();
int noOfComp=1;
if(rs.next())
___________________________________
and put this code where you want to give link on next page:-
if(noOfComp>10) break;
}while (rs.next());
if((start+noOfComp-1)<count)
out.println("<TR><td colspan=6><a href=page5.jsp?start="+(start+noOfComp-1)+">Next Page</a></td></tr>");
}
____________________________________
ALL THE BEST
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64171
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can JavaRanch people help me in accomplishing this.

How are we supposed to do this when you haven't said where you want to display this? A Swing app? Web? Console? PDF document?
Incomplete questions will get you incomplete answers or no answers.
 
ch praveen
Ranch Hand
Posts: 67
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Bear Bibeault,
I want to display results in a webpage.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic