I suspect what you really have to do is set the PDF generation off into a background thread, storing a reference to the thread in the session. Then return with a refresh every 10 - 15 seconds until the thread finishes. Clean up after the thread so you don't end up with memory leaks and possibly implement a listener to clean-up any abandon threads when the session is destroyed.

--David

Kristian Rink wrote:

Hi all,

being aware that this is not a question strictly tomcat-relevant,
lacking a really good mailing-list for discussions closer to the J2EE
background itself, I hope for some input by all the gurus out there.

I'm into a situation like this: A servlet gathers statistical
information across the data in our DMS, is supposed to make a PDF out of
them and send them back to the client who requested them (PDF is demanded).

Problem, however, is that sometimes these computations take quite some
time, leaving me with two situations: (a) The browser itself considers
the connection to be "timed out" as the servlet is stuck in doGet() for
a bunch of minutes. (b) The user itself considers the connection to be
"dead" and closes the browser window. Both situations are uncomfortable.


By now, my initial idea was something like that, utilizing two servlets:

- Servlet 1 processes the request and immediately redirects the client
to another servlet while finishing the calculations and creating the PDF
file.

- Servlet 2 refreshes, say, each 2 seconds, checking whether the file in
question finally has been created and put in place to, then, send this
back to the browser.


This, however, doesn't work out as Servlet 1, even though sending the
Redirect, doesn't redirect until leaving doGet(). So, that's not the
solution...


My question, now: Is there any "usual" / "best-practise" way of doing
something like that, of presenting people with a "please-stand-by" page
while there is activity goin' on in background? Is there a way of
solving something like this without being in need of JavaScript/AJAX/DWR
or something the like?

Any hints, even just pointers to good documentation on that issue, are
very much appreciated.

Thanks and bye,
Kristian




---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to