• Post Reply Bookmark Topic Watch Topic
  • New Topic

looping n displaying records  RSS feed

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iam trying to display the records from a database..using out.print to make an html table and display them. wanted to loop through the records and paginate them. is their a way out to loop thru the records without using the getter and the setter methods of java.
thanks
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you checked the threads on 'ResultSet paging' in the servlet, JSP and JDBC forums? There have been multiple discussions on how to design code that does this effectively.
 
Jeffrey Hunter
Ranch Hand
Posts: 305
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I usually do is use a Servlet, or a JavaBean to retrieve the records, store them in an ArrayList, or HashMap (depending on my needs), and use an Iterator to iterate through each Object and display it on the page. To do so, you can use JSTL, or a JSP scriplet. This way, you need only retrieve the records once, and if you need to access them multiple times, you simply access your data structure, not the database, as the latter is more costly.
Of course, you do not necessarily need to use a getter method. You can simply retrieve the records, and generate the table structure immediately afterwards, though this is a rather crude way to do it, especially if you'll be accessing the data across multiple pages.
[ May 02, 2004: Message edited by: Jeffrey Hunter ]
 
krishnaswamy venkataraman
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by jyotsana dang:
"is their a way out to loop thru the records without using the getter and the setter methods of java.
thanks[/QB]

Yes you can if you use rowset.jar
by usinbg that you can just populate the your resultset into CachedResultSet class and in jsp take out the CachedResultSet and loop thru the same.here you can close ur resultset after populating into CachedResultSet.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!