Tuesday, November 26, 2002 12:06 PM
1.) If you're using a database such as mySQL, you can create a temp table via SQL statement. Explaining this technique would eat up the entire page, so instead check out this link that describes it nicely. This is an ASP example, but the same theories apply whether doing it in a stored proc or doing it with a straight SQL call and in whatever scripting language being used. This is also the fastest and most efficient way of pagination.
2.) When faced with a database that does not support the creation of temp tables (like Interbase/Firebird!), then another possible solution is to create vectors ( or arrays, whichever you like ) in your java code that hold the queried data, then you can loop around and send back only the data that is pertinent to the call (ie Page is 2, Amount of records is 10, so we would loop to element 11 push back elements 11 - 20). This data structure should be kept at the session level so requerying won't be necessary.
3.) Use an existing framework to get the job done. There are many taglibs out there that can most of this up for you.
» Jakarta Taglibs - Page 1.0
Hope that helps!