two solutions cross my mind for pagination: 1. Send the entire resultset as xml and use Javascript + xsl transformation + dynamic html to render HTML with page controls. 2. Use a CachedRowSet and insert it into the session. try this article: http://www.javaworld.com/javaworld/jw-02-2001/jw-0202-cachedrow.html -it's not exactly what you're looking for but it might give you an idea.
zm. -----Original Message----- From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of Tim Panton Sent: Wednesday, February 06, 2002 11:29 PM To: [EMAIL PROTECTED] Subject: Re: How Pagination can be handled optimally ? We faced this a while back, and what we did then was to cache the primary keys of the results (doesn't work for joins) and then get the rest of the data for only the (say) 10 results we were displaying. This mean that the memory usage was limited to a single int per result, but that the complex search was done only once. It also has the nice attribute that things dont shift about if a second user is updating records (although they may no longer meet the criteria). Anyhow, we mostly let the database worry about it these days, Oracle (and I assume others) has specific construct to help here (MAXROWS etc), and will cache query results if it can. (Actually we hardly ever do JDBC queries at all these days, prefering to use an XML layer instead, but thats a whole other story) Watch out for containers that serialize your session, a big cache will turn into a preformance nightmare. Matt Penner wrote: > > I'm not sure what the overhead would be like but rather than saving the data in > a session variable what would the performance hit be if the returned search > results were saved in a temporary table in the database? Save it in a > temporary table with an autoincrement column and name the table with a naming > convention that would uniquely identify it against a user session variable such > as their username. Then you just query the table each time giving a range for > the autoincrement column. > > Any thoughts on this? I just kind of picked it up right now. This would take > a lot of the stress off of the container and any overhead from maintaining > large session variables. Especially if you have a robust db system. You may > have to implement your own garbage collection to remove the temporary tables if > it hasn't been accessed in more than say 5 minutes. > > ~Matt > > Quoting Jo�o Robertson Kramer Santana <[EMAIL PROTECTED]>: > > > Until now I havent found a good solution for this problem. Today > > I > > save the key of the last record showed in the user form . When the > > user > > submits the form I : > > 1) open the cursor again (I save the query parameters in the form too) > > 2) if he pressed the "Next" button then move the cursor to the saved key > > and > > show "n" more records > > 3) if he pressed the "Back" button then move the cursor to "n" records > > before the saved key > > 4) save the key of last record showed in a form variable > > 5) save the query fields in forms variables > > 6) response > > > > I cant make any cache because i dont know how big would be the > > query > > result. I would like to know others solutions for this problem, because > > the > > one I use gives me a lot of work! > > > > bye > > > > jk > > > > ___________________________________________________________________________ > > 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 ___________________________________________________________________________ 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
