• Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying results after retriving from db  RSS feed

 
pavi kavi
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
I am working on search engine functionality.
I want to know how u display after retriving the data from the database .Suppose i get 5000 search results i want to display 1-25 in a page & when he pressses next it should display him in the next 25 & so onn.
Can anyone please give me the code or logic how to do it
I am using servlet,JSP,EJB & weblogic6.0 & oracle database
Please its very urgent
Thnaks in advance
pavithra
 
Arun, Shanmugham
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The same situation came for me while displaying the catalog in a Shopping Application. U can do the following
1. u can display the first 25 records and break the while loop.
2. If the user clicks the next button , call the same servlet. This time pass the number of records already displayed as a parameter to the servlet.
3. While displaying the next 25 records, read the parameter from the request object for no. of records already displayed, then move to the record after that using resultset.relative(<row number> ), or skip that much records using anther while loop.
4. Now show the 25 records in the actual while loop and pass the number of records passed again to the same servlet or jsp.
Hope this will give u the idea. I think u can even store the number of records displayed in a cookie or session object.
Arun
SCJP
 
prabhatis
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
there r two solns for this.
1. create a bean to store the results of the query in a vector
and give it a session scope. pass the 'start'-prev and 'end'-next record no as parameters to it and retrieve the rows as needed. if u can't do by this idea then i can give u code ..but better u try first
2.use the suggestion as given by the arun ..but in this approoach u have only forward traversing(jdbc1.0) both directions(jdbc2.0) but u have to keep open the resultset object and this is cumbersome
i hope it will help u
PRabhat kumar
have a nice time in coding
 
Arun, Shanmugham
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi prabhatis,
U can do the same process which i mentioned by storing the datas from the open resultset into a vector and later use the vector for access the data.
Arun
SCJP
 
pavi kavi
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
can u please send me the code it will be more useful
But i donot want to store the data since the load on the server will be more.
thanks in advance.
pavithra
Originally posted by prabhatis:
there r two solns for this.
1. create a bean to store the results of the query in a vector
and give it a session scope. pass the 'start'-prev and 'end'-next record no as parameters to it and retrieve the rows as needed. if u can't do by this idea then i can give u code ..but better u try first
2.use the suggestion as given by the arun ..but in this approoach u have only forward traversing(jdbc1.0) both directions(jdbc2.0) but u have to keep open the resultset object and this is cumbersome
i hope it will help u
PRabhat kumar
have a nice time in coding

 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!