> We're using Struts, Java server classes, and Tomcat.  Our server will
> eventually be Linux (currently win 2k.)  Is there a way to end a users
> session if the browser has closed either through user action or non-user
> actions such as power outages?  If not, what are typical ways to get
> around
> this?  We are talking about allowing the user to login again, checking for
> a
> current user session, and if they have one, killing it and starting a new
> one.  Does this make sense?  Thanks.

typically, servers offering session handling (like tomcat) have a standard 
feature of cleaning up sessions after a period of inactivity from the
client.
this timeout period is configurable (look at  the method 
setMaxInactiveInterval(int�interval) in class
javax.servlet.http.HttpSession,
when this value is negative, the session never times out)
and usually also has a default value.
of course this timeout also works when the browser is not closed and
the client just waits too long. so, finding a sensible value for your
application
depends a lot on the way in which users will interact with your app.

as to logging in again and searching for an existing session...
the session-id is created by tomcat when a new session is requested
(look at getSession() and getSession(boolean b) in HttpServletRequest) 
if you store the session-id on the server (getId() in HttpSession) 
and do not invalidate the session, it is possible to check for another 
login of the same user and re-use the HttpSession-Object.
(you could even make the session immune against server-restart by
making storing the information in a persistent object that is serialized
to disk when the server shuts down and then de-serialized on startup)
the problem is, you cannot distinguish wether the browser has really crashed
or was closed (or similar) or the user is just trying to log in again... 
if you just request a new session on new login, the "killing" is automatic,
because you get a new HttpSession object and a new session-id.
hope this helps
greetings

-- 
GMX - Die Kommunikationsplattform im Internet.
http://www.gmx.net


To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm

Reply via email to