Matt Feiszli wrote:

> First, thanks for the info.  But I think I framed the question poorly.
> This will solve some of my problems, but if I have a long-running
> computation that produces no output until it's done (e.g. long database
> query), the query will still run to completion before the servlet can
> find out.  I'd like to get interrupted or notified somehow, analogous to
> getting a SIGPIPE if I were in a normal UNIX environment.  I suppose I
> could rewrite the servlet to send a little bit of whitespace every so
> often while it's waiting for the query results, but this seems ugly.  It
> would be nice if there were a cleaner way.  There's nothing in the
> servlet API that seems to address this.
>
> -Matt
>

Another strategy I've heard people say they used in this situation is to
start the long-running computation in a background thread, which will store
its final results into a user's HttpSession.  Then, your servlet can return
immediately after the computation is started, with a "computation in
progress" message.  Each time the user invoked the servlet again, it would
see that the computation was still running (and say so again), or that it
has been completed (and display the results).

You could get even fancier and do a "% completed" indicator for the progress
that the computation is making, or give the user an option to interrupt the
ongiong computation if they decide that they don't want to wait for the
results to be completed.

Craig McClanahan


>
> jon * wrote:
> >
> > > Is there any way for a servlet to figure out that
> > > it's sending data nowhere, or are there any plans for such a feature?
> >
> > I believe that it is possible because you will get a IOException if the
> > outputstream is closed.
> >
> > -jon
> >
> > -- --------------------------------------------------------------
> > To subscribe:        [EMAIL PROTECTED]
> > To unsubscribe:      [EMAIL PROTECTED]
> > READ THE FAQ!!!!     <http://java.apache.org/faq/>
> > Archives and Other:  <http://java.apache.org/main/mail.html/>
> > Problems?:           [EMAIL PROTECTED]
>
> -- --------------------------------------------------------------
> To subscribe:        [EMAIL PROTECTED]
> To unsubscribe:      [EMAIL PROTECTED]
> READ THE FAQ!!!!     <http://java.apache.org/faq/>
> Archives and Other:  <http://java.apache.org/main/mail.html/>
> Problems?:           [EMAIL PROTECTED]



-- --------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
READ THE FAQ!!!!     <http://java.apache.org/faq/>
Archives and Other:  <http://java.apache.org/main/mail.html/>
Problems?:           [EMAIL PROTECTED]

Reply via email to