I have a web application , that helps download reports.
But the report generation sometimes takes a lot of time, and the web request times out through the intermediate proxy server.(Timeout :90 secs).
The workflow for downloading the report is straightforward. Client sends request to the web server. The web server generates the report , and makes it available to the client as an excel download.
The excel is generated using POI and the download is provided using Spring's AbstractExcelView.
What could be the best way to keep the web request alive(without increasing the timeout , of course) ?
views:
69answers:
2One way is to make the initial request return a holding screen saying, "We're generating the report..." including a request token and JavaScript (typically AJAX) to pass that request token back to the web application periodically to see if the report is done, and display it when it is.
If you have any indication within the web app code of how far the report has got, that progress can be communicated back through the AJAX too.
That way each request is answered in a reasonably short period, but the report generation "session" is kept alive by the token ID. When the report is finished on the server you'd probably want to store it in a cache somewhere until it's requested - and expire it after a while, in case the browser has been closed.
Oh, and a nice side effect I didn't mention before - the user gets to see that the web app is still alive, and they've still got a network connection to it. Leaving a cursor spinning for a couple of minutes can be unnerving :)
Have you tried using a COMET enabled server ? You can keep a long running request alive by using a variety of techniques like COMET or even long polling. Or a simple AJAX alive ping to the server should do the trick. Reload the page using Ajax when you know that the report has been generated.