Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

urgent urgent .....How do i do paging in JSP ?????

 
DeepakB
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thru JSP, i want to display nearly 100 OR MORE THEN THAT records. in the first page it has first 10 records, next page has next 10 records and so on.. page: 1 2 3 4 5 6 7 8 9 10 (page no) when i select 1, it will show 1st page of first 10 records,if i select 2 it will show 2nd page of records starts from 11 to records 20 ... and so on.....
my back end is: MS SQL 7.0
DEEPAK
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"DeepakB",
The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please log in with a new name which meets the requirements.
Thanks.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well you can store the records retrieved from the database into one of the collection classes. Now you can easily traverse through the records.
 
Deepak B
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnx parmeet
but , its huge database ,may be 500000 or more record, i want to display records. in the first page it has first 10 records, next page has next 10 records and so on.. page: 1 2 3 4 5 6 7 8 9 10 (page no)
Note : Data base is growing 1000 record every day so not possible to used any of collection or vector java class..
is there any method which directly retrive data from table and through java code in JSP page , i can divide that in to 10 record per page .

Thnx in advance
Deepak
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. Put the entire result set into a collection of some kind ( array, or any collection object from java.util). If the rows of your query can be represented as objects, then create an object for each one and store the collection of objects as an ArrayList. Put the collection into the users's session, like this: session.setAttribute( "pageResults", myCollection );
2. create a page that displays the first N objects in your collection.
3. create a forward and backward links in your page that are numbered, with each number corresponding to N items in your collection. For example, if N=20 and page number is 0, you display the first 20 items; if page number is 1, you display items 21-40, etc. Of course if you're on the first or last page the backward and forward links should be disabled, respectively.
4. create an OutofMemory Error if result set is large
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic