----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files.  Don't make us guess your problem!!!
----------------------------------------------------------------

First of all, I think you can get around the browser-stop problem by not 
writing any output
until all DB operations are complete.  The servlet will not know that the 
client has closed
its connection until it tries to write -- so you'll be able to complete 
your operations,
you just won't be able to send anything back.

If you really need some asynchronous processing, here's one approach:

- You use threads and sessions.  Prepare for the needed URL rewriting, 
cookies, etc.
- Implement a new thread object to do your DB stuff.
- In the servlet that receives the client request, create a new instance of 
the thread object,
initialized with whatever parameters you need.  Then save the thread object 
in the session.
- The thread object should implement SessionBindingListener (I think that's 
the name).
This will allow the thread to get  a reference to the session it was 
stashed in. Probably,
the place to store the results of your DB stuff is also in the session.
- If the user checks status of the DB operations, look at the thread object 
in the session,
and get the DB status from that.

This assumes that there's a need to get status on an operation in 
progress.  Otherwise,
you could just start the thread and not save it in a session.  Sessions are 
useful things,
but if you're talking about 100,000 simultaneous users invoking this 
function, you
probably want to try some other approach.

If implementing threads or working with sessions is new to you, you 
probably will want to
do some more basic research before implementing your feature.

- Fernando

At 02:48 PM 9/6/00 +0100, you wrote:
>----------------------------------------------------------------
>BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
>WHEN YOU POST, include all relevant version numbers, log files,
>and configuration files.  Don't make us guess your problem!!!
>----------------------------------------------------------------
>
>
>I have a Servlet that processes some database queries while the user waits
>and the problem I'm having is if the user stops the Servlet by pressing stop
>on there browser  in mid processes the database does not get updated. How do
>execute a java object within a Servlet that will not  stop before it has
>finished
>
>Thank you
>
>James
>
>
>--
>--------------------------------------------------------------
>Please read the FAQ! <http://java.apache.org/faq/>
>To subscribe:        [EMAIL PROTECTED]
>To unsubscribe:      [EMAIL PROTECTED]
>Search Archives:
><http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
>Problems?:           [EMAIL PROTECTED]



--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Search Archives: 
<http://www.mail-archive.com/java-apache-users%40list.working-dogs.com/>
Problems?:           [EMAIL PROTECTED]

Reply via email to