There is a method that can be used to detect whether
the client has closed teh browser or pressed the stop
or forward or back button.
The response interface has a method called
checkError(). When the servlet tries to write to the
response stream, there's no client at the other
end,(assuming that the stop button has been pressed or
browser has been closed. At this point the checkError
method returns true. So in your code you can have:
 if (res.checkError()) {
     session.invalidate;
 }
This is 100% reliable & works all the time.
Girish
--- Milt Epstein <[EMAIL PROTECTED]> wrote:
> On Tue, 31 Oct 2000, Gokul Singh wrote:
>
> > > The problem is:
> >
> > >  -Closing my internet explorer(don't know)
> >
> > If you are using the cookies or URL rewriting for
> maintaining
> > session, then closing the IE will automatically do
> it for you.
> [ ... ]
>
> This may not be sufficient, depending on the exact
> requirements.
>
> With regard to a session, there are two things that
> are needed: the
> session id (which acts as a "key" to access the
> session), and the
> session itself.  The id is a client-side thing, and
> can be passed
> either via a cookie or, with URL rewriting, as part
> of the URL.  The
> actual session itself is on the server-side.  The id
> may be gone when
> the browser is exited, but the session will still be
> there.  Closing
> the session itself can only be done on the server
> side, via an
> explicit call to invalidate(), or a timeout (you can
> control the
> timeout period).
>
> Being able to detect, on the server-side, a browser
> closing, or
> someone stopping a page from being loaded, or going
> to another page,
> has been discussed *a lot* on this list.  The
> consensus is that
> there's no 100% reliable way to detect these things.
>  This means that
> you are going to have to rely on the session timeout
> mechanism to
> close sessions.
>
> Milt Epstein
> Research Programmer
> Software/Systems Development Group
> Computing and Communications Services Office (CCSO)
> University of Illinois at Urbana-Champaign (UIUC)
> [EMAIL PROTECTED]
>
>
___________________________________________________________________________
> 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


__________________________________________________
Do You Yahoo!?
>From homework help to love advice, Yahoo! Experts has your answer.
http://experts.yahoo.com/

___________________________________________________________________________
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

Reply via email to