public class MyObject implements HttpSessionBindingListener {
    private boolean interesting = false;
     ...

    public boolean isInteresting() {
        return interesting;
    }
    public void setInteresting(boolean yesno) {
       interesting = yesno;
    }
    public void valueUnbound(HttpSessionBindingEvent event) {
        if( isInteresting() ) {
           // do something here.
        }
    }
    ....
  }

When you create the interesting one, set it to be interesting.  All the
other objects will just no-op on unbound.

"Alexander Wallace" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I gave that a try, the problem with it is that my session has many
instances
> of that same object, but it is only one instance the one I'm interested
on.
> That's why i wanted to pull it out of the session since I can retrieve the
> particular one by name...
>
> Any ideas?
>
> On Monday 17 March 2003 10:44, mike jackson wrote:
> > Value bound and unbound is the way to do this.  I have an object that
> > creates and destroys "temp" tables in my database this way.  It's kinda
> > clunky, but it works.
> >
> > When the object is unbound (either it is removed from the session or the
> > session is invalidated) you'll get an event.  As long as you don't
> > remove the object yourself you ought to be mostly ok.  With tomcat 3.x I
> > have the issue that sometimes I have to kill -9 tomcat (not often) which
> > doesn't trigger the value unbound event, but it's mostly ok.
> >
> > --mikej
> > -=-----
> > mike jackson
> > [EMAIL PROTECTED]
> >
> > -----Original Message-----
> > From: Alexander Wallace [mailto:[EMAIL PROTECTED]
> > Sent: Monday, March 17, 2003 8:23 AM
> > To: Tomcat Users List
> > Subject: Get object from session before it expires.
> >
> > I've been searching and just want to make sure I was told correctly.
> >
> > I was told in an IRC that there is no way to get an object from a
> > session
> > before it expires.
> >
> > I know you can listen for valueUnbound, but that tells me when all
> > instances
> > of a class are being unbound.
> >
> > I know you can listen to sessionDestroyed and get the session from the
> > HttpSessionEvent, but by then the session has already been invalidated
> > and I
> > can't get a hold on a particular object.
> >
> > What I need is to know before a session is invalidated, so that I can
> > pull a
> > particular instance of a class from the session and update a database
> > with
> > it.
> >
> > I was told that is not possible... Is this right? Any suggestions?
> >
> > Thanks in advance!
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to