Handling Time Consuming Requests
Domininic says, "I am try to find a good way to have an intermediate page load up while my Struts Action performs a large database query and then XSLT transformation." Ask and ye shall receive. I received the following e-mail from Alec Missine a while back. The attachment has a method of implementing a TCR. Let me know how it works as I haven't tried it myself.
----- Original Message -----
From: Alec Missine
To: [email protected]
Sent: Monday, January 07, 2002 3:59 PM
Subject: processing time consuming requests (was: wait page primer)
There's been some interest to the message I posted last month on the subject. The war file was too big though, so I compressed the stuff as much as I could. I also added some javadoc and UML diagrams.
The attached Struts-based application prototypes the wait page support for a time-consuming request (TCR). When a TCR (e.g., a database search) starts, the appropriate wait page is being sent to the browser after the request's ETC (Estimated Time to Complete) expires.
In the meantime, the corresponding action (the database search) is being started in the background thread on the server. If the default ETC is used (ad infinitum) or the action completes before the request's ETC expires, there is no wait page at all - the browser gets the result page right away, while the background thread is still busy closing the resources.
The wait page has javascript that polls the server to update the wait page with the TCR's progress. When the TCR completes, the wait page is being replaced with the appropriate result page.
This implementation has been tested on Apache Tomcat 4.0 with an Oracle 8.1.6 database as a data source. Presently, the application provides read-only access to all database tables for all database schemas through extensive use of the java.sql.DatabaseMetaData object. The next release will support insert/update/delete functionality.
Alec
Attachments: tcr.zip (114 KB)
Hope this helps!
Posted by dsuspense on November 13, 2002 at 03:50 PM MST #
Posted by Leo Hart on July 16, 2003 at 08:24 PM MDT #
Posted by Matt Raible on July 17, 2003 at 10:50 AM MDT #
No threads and its generic
Posted by David Martin on December 06, 2003 at 01:10 PM MST #
Posted by antonella balduzzi on February 11, 2004 at 10:23 AM MST #
Posted by Pipo Inzagi on May 09, 2007 at 12:28 PM MDT #