This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes logic to display certain number of records in JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "logic to display certain number of records in JSP" Watch "logic to display certain number of records in JSP" New topic
Author

logic to display certain number of records in JSP

Neha Sharma
Ranch Hand

Joined: Jul 13, 2001
Posts: 126
Can anybody suggest me on the logic how to build a jsp in which I need to display 10 records from the resutlset on each. At the bottom of the page I have to display href values page 1 of 7 , 2 of 7 and so on. When the user clicks on any of them I have to show the data. I not able to think of a logic how can I achieve that.
Thanks
Neha
Jeff Sunder
Ranch Hand

Joined: Jun 26, 2001
Posts: 47
You can put your results in a vector, then loop through your vector to display the results.
Dave Soto
Ranch Hand

Joined: Sep 15, 2001
Posts: 55
One thing to be careful of when storing results (presumably in the session) of a query is that you have to make sure your database isn't too large. What if a search returned 50,000 rows? You don't want to save a 50,000 row vector into a session. All you need is a handful of users to nail you with some searches like that and you are looking at some big memory consumption on your app server.

That's what EJB is for, but that's a whole different discussion.
Sid Scud
Ranch Hand

Joined: Mar 13, 2001
Posts: 32
Hi Neha,
I have implemented the same thing. You can go for CachedRowsets than going for ResultSets. Going thru CachedRowset is easier and it provides many methods which are very useful.
C if itt works on your side too... atleast it gave me good and fast results.
-Sid
Kareem Gad
Ranch Hand

Joined: Aug 06, 2001
Posts: 89
Siddarth,
I tried to find where in the Java API is this CachedRowSet class ?
Can you please clear this out ?

------------------
KaReEm


<b><i>KaReEm</i><br /><ul type="square"><li>SCJP-Free Range Web Developer <br /></ul></b>
Kareem Gad
Ranch Hand

Joined: Aug 06, 2001
Posts: 89
How i would usually go about something like this and i've done it before is to pass boundary parameters to the page the will show the results, so by default these parameters would be 0, 20 let's say if u want to show 20 records.
and then if i will provide a next link at the end of the 20 rows i pass the next set of boundary parameters 20, 40 and so on
it really depends on how your database manages it , for mySQL you give a limit [start_row],[number_of_rows] format
for oracle you give a condition something like
where rownum < 20 something like that.

------------------
KaReEm
Sid Scud
Ranch Hand

Joined: Mar 13, 2001
Posts: 32
Hi Kareem,
Here is the link where u get the specs and the jar file.
http://developer.java.sun.com/developer/earlyAccess/crs/
(u need to be a JDC member)
Hope it helps u.
-Sid
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: logic to display certain number of records in JSP
 
Similar Threads
how to achieve pagination on jsp
controlling jsp:forward
Displaying more than 500 records per page in a jsp
Paginate in JSP
display area problem