File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Tables in servlets/JSP(Urgent !!) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Tables in servlets/JSP(Urgent !!)" Watch "Tables in servlets/JSP(Urgent !!)" New topic
Author

Tables in servlets/JSP(Urgent !!)

amit malhotra
Ranch Hand

Joined: Aug 06, 2001
Posts: 30
i am qureying an oracle database and i want to display the results in a table having only 20 rows ,the next 20 rows should be displayed in the next page and so on and depending on the number of rows dynamic links should be generated say as we have in google search,could some one help me out with the logic/URL'S etc.any replies would be welcomed....
Kameswari Jyosyula
Ranch Hand

Joined: Feb 20, 2001
Posts: 39
Did u find an answer to that, if so post it here plz
Manjunath Reddy
Ranch Hand

Joined: Jul 26, 2001
Posts: 60
As far as i see, there is no concept of disjointed recordsets in JDBC. Hence one has to create a kind of caching to achieve this. Previosly i had done this by maintaining a display counter variable in a session bean(which is toggled through the jsp's href), and fetching every time only that results that are defined by counter variable + FETCH_COUNT(say 20).
The problem with this was..even though i show only 20 at a time i had to still go through the whole resultset when user browses more than 20 results...
Another way is to serialize the results into a file and serve 20 from the file...but this leads to threading issues when on EJB servers..
Hope this gets u going and maybe someone might have better ideas..
amit malhotra
Ranch Hand

Joined: Aug 06, 2001
Posts: 30
Hello Manjunath,
thanx a lot for the reply, But as far is EJB is concerned I am totally blank,Is this the way normal search engines like Google do it,please reply back
Bala Ramachandran
Greenhorn

Joined: Aug 20, 2001
Posts: 12
Originally posted by amit malhotra:
Hello Manjunath,
thanx a lot for the reply, But as far is EJB is concerned I am totally blank,Is this the way normal search engines like Google do it,please reply back

Hi,
The way I did this is:
When you get the results from the JDBC or any other call, store the results in a vector and a current index variable in the session (the index variable is to indicate the last row that is being displayed). If you are currently going forwar in the resultset, this will be the last row displayed among the 20 rows. If you are going backwards, this will be the first row among the 20 rows.
Give the users choice to get the previous 20 results or the nex 20 results. The URL for forward or reverse should have a flag that indicates to the JSP what to do (reverse or forward).
Based on which link they click, use the vector in the session, current index variable in the session and just decrement or increment from the index variable and show those elements from the vector. Also make sure you update the index variable to indicate the current position of the access.
Hope this helps.
Bala.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Tables in servlets/JSP(Urgent !!)
 
Similar Threads
How to display variant number of record each page based on user's request ?
how to Setnumber of rows per page and max number of rows
Paging
Add values of a column
How to display variant number of record each page based on user's request ?