Amarnath Nanduri wrote:
>
> Miss,
>      Two ways of finding out.
>      First ...every user has a Session Object. The time of survival for
> this object is set by the Web Administrator. Default value is 30 minutes.
> After 30 minutes, the user's Session Object is reclaimed by the JVM for
> memory. User's session object becomes  'null' then.

A session is only created if a servlet explicitely calls
HttpServletRequest.getSession(true).

>      Second....whenever the user exits out of the web-browser, the session
> object is automatically made null.

Well, only if the user exits your web application through a logout servlet that
you have provided that calls HttpSession.invalidate().

The server has no way of knowing the user is leaving the web site so
unless you tell it explicitely (through a logout servlet), the session will
time-out after some time (default 30 minutes) of user inactivity.

> So if you encounter a 'null' session object then it is a safe bet that the
> user has logged out/timed out .
> Hope this helps.

I would suggest that the best way to handle the original question in this
thread (how to close a DB connection when the user leaves) is to wrap the
connection in an object implementing HttpSessionBindingListener and put this
object in the session. The valueUnbound method is called when the session ends
(timed-out or explicitely inactivated). You can therefore close the connection,
or return it to a pool, in this method.

---
Hans Bergsten           [EMAIL PROTECTED]
Gefion Software         http://www.gefionsoftware.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