Hi,
I think we should use the creation time of the session as the starting
time.............instead of the current system time at time when valueBound
is called.....because we are binding the object with the session ourself and
that is after the creation of the session...
Thanks anyway for replying
Bye
----- Original Message -----
From: "Bo Xu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, March 11, 2001 10:35 PM
Subject: Re: record the total session time
> Nauman Rafique wrote:
>
> > Hi,
> > I am trying to keep a usage record for each user who connects to my
servlet.
> > So I need some function which is called when a session is
destroyed.....so
> > that i can record the creation and termination time for a
session.........
> > Can any body tell me if there is some function like that or how to keep
the
> > usage record???
> >
> > Thanks in advance
> > [...]
>
> Hi :-) from a email in Servlet-List, I suggest you try the following:
>
> - when a object implementing
javax.servlet.http.HttpSessionBindingListener
> is bening added to a HttpSession, the method valueBound() will be
> invoked; and if this object is being removed from this HttpSession,
> the method valueUnbound() will be invoked.
> - so if we are sure that we don't add/removed this object by ourself,
But
> the valueBound()/valueUnbound() is/are still invoked, then we can
believe
> that the reason is: this Httpsession is caeated/invalidated (or
"timeout")
> - so in this case, I think you can use valueBound()/valueUnbound() to
> record the creation and termination time for a session. the
following
> is a sample code I study from that email:
>
> import java.io.*;
> import javax.servlet.*;
> import javax.servlet.http.*;
>
> class Recoder implements HttpSessionBindingListener{
> public void valueBound(HttpSessionBindingEvent evt){
> System.out.println("in CleanUp, valueBound...");
> }
>
> public void valueUnbound(HttpSessionBindingEvent evt){
> System.out.println("in CleanUp, valueUnBound...");
> }
> }
>
>
> and you can use this Recoder class in your Servlet, for example:
> ...
> session=req.getSession(true);
> ...
> session.setAttribute( "Recoder", new Recoder() );
> ...
>
>
>
>
> Bo
> Mar11, 2001
>
>
___________________________________________________________________________
> 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
>
___________________________________________________________________________
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