*
The moose likes JSP and the fly likes iterating thru records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "iterating thru records" Watch "iterating thru records" New topic
Author

iterating thru records

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
i have a browsing page in jsp that will show 5 records at a time. I want to figure out how to make the user select the next button and be able to see the next 5 records if present and so on. Do i use javascripting for this functionality..or can this be implemented in jsp itself..
thanks
Andres Gonzalez
Ranch Hand

Joined: Nov 27, 2001
Posts: 1561
Have a look at the pager taglib. Very easy to use.. no need javascript at all
good luck


I'm not going to be a Rock Star. I'm going to be a LEGEND! --Freddie Mercury
jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
iam not able to implement pager tag properly in my page..
Winston Smith
Ranch Hand

Joined: Jun 06, 2003
Posts: 136
The problem with iterating like this is, everytime the user wants to see the next 5, it will involve a trip to the server, where the JSP will be initialized to the next five records. This may or may not be a problem, depending on the round trip delay. If your records are rather simple, you can mirror them with javascript objects, and simply store them all in a javascript array, so the user will be able to scroll through them freely without incurring the overhead of a trip back to the server.
WS


for (int i = today; i < endOfTime; i++) { code(); }
danny liu
Ranch Hand

Joined: Jan 22, 2004
Posts: 185
you could put all records in session and retrieve 5 records every time.
Dan
Joe Pardi
Ranch Hand

Joined: Oct 03, 2001
Posts: 47
Take a peek at the dotJ grid component:
http://www.dotjonline.com/main/index.jsp?url=/taglib/grid/grid.jsp
jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
i have atleast 50 records as of now in my database.. whcih will keep on increasing..
Joe Pardi
Ranch Hand

Joined: Oct 03, 2001
Posts: 47
Regardless of your solution, you will want to limit the number of records that is retrieved from the database. If you have alot of records to query, then a scrollable Resultset can be used to minimze the number of rows you actually traverse through. This reduces the amount of data sent over the wire.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: iterating thru records
 
Similar Threads
iterating thru records
retrieving data pagewise
vector
urgent urgent .....How do i do paging in JSP ?????
looping thru records