>>> Raj Patel <[EMAIL PROTECTED]> 10/6/99 7:19:10 PM >>>
>I want to be able to kill the connection and data transfer
>if the user jumps to another page before the actual retrieval has
>finished. Is there any way using session management to determine
this?
No.
But then... (as with everything) ...yes.
When the user leaves the page you can fire a JavaScript event...
(can't remember off hand what this is).
Here's how you might use that
1. you output the page from the servlet
2. the servlet puts the JS into the page to fire up another window
(or some other way of getting a connection to a web server)
3. the JS code has the session-id encoded in it
4. your servlet receives the request when the user causes the page to
be left.
This is extreemly nasty. I would recomend having some other method.
For example...
1. do the socket connection if the doGet() (or service() or whatever
you're using)
2. the user will then have to either wait for the connection to be
completed and all the data to be
sent...
3. ...or leave the page which will end the connection to the server
and cause an IOException (if your server handles IO properly - you
might have to out.flush() first...)
4. you can catch the IOException to be told when the user has left
the page
You can do all sorts of clever things with this... for example:
1. start a seperate thread to connect the socket and collect the
data
2. use thread status checking to detect when the thread is done
3. whilst it is not done simply write out 0x20 to the client at
regular intervals (multiple spaces don't get displayed in HTML).
Hope that helps.
Nic
___________________________________________________________________________
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