You can run a background Thread (it won't be killed when the servlet initiating
the thread sends it's response). You can then do a variety of things to report
back to the user that the operation has been completed.
1) Easiest way -- mail them the results. The thread will be responsible for
knowing who to mail the results to, and will perform the mailing.
The other mechanisms involve storing the thread statically, so that it can be
referenced by a servlet. You may want to create, for example, a statically
stored Hashtable, whose keys are some unique identifier for the user (i.e. a
user ID), and whose value is a Vector of objects, each containing (or may
themselves be) the Threaded process.
2) Create a servlet that the user can execute to check on the status of threads
that he has initiated. If a thread is completed, the user can view the results
of the thread execution via the servlet.
3) Combo of 1 & 2 -- mail them that the operation has been completed, and
provide a link to a servlet that will display the thread results to them.
4) If the user isn't going to do anything other than wait for the operation to
complete, you can have your page automatically refresh (with <META http-equiv>
syntax), calling the servlet every x seconds/minutes, which in turn will check
on the status of the thread, etc.
Bruno Lowagie wrote:
> I have a servlet that starts a long series of calculations.
> The calculations can take up to 30 minutes.
>
> This leads to 2 problems:
> 1. The timeout of the server is less than 30 minutes,
> so we get a 'document contains no data'.
> 2. We don't want to raise the timeout, because a user
> won't usually wait that long.
>
> We thought of the following solution:
> 1. The user calls a servlet.
> 2. This servlets starts a process in background that calculates
> a result and writes it to a file on the server.
> 3. The user gets an immediate response with the URL of this file,
> so he can visit this URL once the calculations are finished.
>
> What is the best way to do this? A servlet calling another servlet?
> Starting a thread (but won't this thread be killed once the servlet
> has sent his response)?
>
> Is there a means to let the user know when the calculations are done
> to prevent 404 errors or having to look at an incomplete result?
>
> Thanks in advance,
> Bruno
>
> ___________________________________________________________________________
> 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