Try to use the J2EE Page by Page Iterator pattern which is just meant for it. Retrieving the whole information will be bottleneck for the performance.
Have a look on http://java.sun.com/j2ee/blueprints/design_patterns/page_by_page_iterator/index.html "[Aruniima Chakrabarti]" <Aruniima.Chakrabarty@IFLEXSOLU To: [EMAIL PROTECTED] TIONS.COM> cc: Sent by: "A mailing list for Subject: Re: Pagination in JSP discussion about Sun Microsystem's Java Servlet API Technology." <[EMAIL PROTECTED]> 04/24/02 06:10 PM Please respond to "A mailing list for discussion about Sun Microsystem's Java Servlet API Technology." Hi Arun, This can be done using JavaScript. You can get the desired set of records from the database & display those records using JavaScript functions. I am enclosing the code below for a program which allows you to display data from the database, one record at a time. & allows the user to move back & forth the records. Also, delete, modify, add records to the database. Regards, aruniima <jsp:include page="../menuadmin.htm"/> <jsp:useBean id="usr" class="classes.db.User"/> <% String recs[][]=user.retrieveAll(); %> <html> <head> <script> var NO_OF_RECS var CURR_REC_NO=0 var recs=new Array(<%=recs.length%>) var id for(var i=0;i<recs.length;i++) recs[i]=new Array(<%=recs[0].length%>) <% for(int i=0;i<recs.length;i++){ for(int j=0; j < recs[i].length ; j++){ %> recs[<%=i%>][<%=j%>] ="<%=recs[i][j]%>" <% } } %> NO_OF_RECS=recs.length id=recs[0][0] function assign(){ document.frm.userID.value=recs[CURR_REC_NO][0] document.frm.userName.value=recs[CURR_REC_NO][1] document.frm.userPassword.value=recs[CURR_REC_NO][2] document.frm.userType.value=recs[CURR_REC_NO][3] } function moveFirst(){ CURR_REC_NO=0 id=recs[CURR_REC_NO][0] assign() } function movePrev(){ CURR_REC_NO-- if(CURR_REC_NO==-1) CURR_REC_NO=0 id=recs[CURR_REC_NO][0] assign() } function moveNext(){ CURR_REC_NO++ if(CURR_REC_NO==NO_OF_RECS) CURR_REC_NO-- id=recs[CURR_REC_NO][0] assign() } function moveLast(){ CURR_REC_NO=NO_OF_RECS-1 id=recs[CURR_REC_NO][0] assign() } function showusermod(){ window.location="showusermod.jsp?id=" + id } function userdel(){ if(confirm("Are you sure you want to delete this record")){ window.location="del.jsp?id=" + id } } </script> </head> <body onLoad="assign()"> <center> <b> Administration for Users </b><br> <form name=frm> <table> <tr> <td> UserId: </td> <td> <input type=text name="userID" onKeyDown="return false"> </td> </tr> <tr> <td> UserName: </td> <td> <input type=text name="userName" onKeyDown="return false"> </td> </tr> <tr> <td> User Password: </td> <td> <input type=text name="userPassword" onKeyDown="return false"> </td> </tr> <tr> <td> User Type: </td> <td> <input type=text name="userType" onKeyDown="return false"> </td> </tr> </table> <table> <tr> <td><input type=button value="<<" onClick="moveFirst()"></td> <td><input type=button value=" < " onClick="movePrev()"></td> <td><input type=button value=" > " onClick="moveNext()"></td> <td><input type=button value=">>" onClick="moveLast()"></td> </tr> </table> <table> <tr> <td><input type=button value="Add" name="addbutton" onClick="window.location='showuseradd.jsp'"></td> <td><input type=button value="Modify" onClick="showusermod()"></td> <td><input type=button value="Delete" onClick="userdel()"></td> <td><input type=button value ="Close" onClick="window.close()"></td> </tr> </table> <input type=hidden name="hid"> </form> </center> </body> </html> -----Original Message----- From: Arunkumar_N [mailto:[EMAIL PROTECTED]] Sent: Wednesday, April 24, 2002 3:54 PM To: [EMAIL PROTECTED] Subject: Pagination in JSP Hello, Is there any logic to display 10 records at a time,where data is obtained dynamically from Database & a button to navigate back & forth in JSP. Please look into this Regards Arun ************************************************************************** This email (including any attachments) is intended for the sole use of the intended recipient/s and may contain material that is CONFIDENTIAL AND PRIVATE COMPANY INFORMATION. Any review or reliance by others or copying or distribution or forwarding of any or all of the contents in this message is STRICTLY PROHIBITED. If you are not the intended recipient, please contact the sender by email and delete all copies; your cooperation in this regard is appreciated. ************************************************************************** ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ---------------------------------------------------------------------------- This message contains privileged and confidential information and is intended only for the individual named. If you are not the intended recepient you should not disseminate, distribute, store, print, copy or deliver this message. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and immediately delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. -------------------------------------------------------------------------- ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html ___________________________________________________________________________ To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
