You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jon Eaves <jo...@eaves.org> on 2002/12/28 13:07:53 UTC

Servlet/Session/Attribute Listeners not very useful ?

Hi all,

Can anybody tell me what possible use these particular interfaces
are ?

After thinking that they would be a good idea to use for web app
session management enhancements (session timeout etc) it turns out
that the invocations of valueUnbound(), sessionDestroyed(),
attributeRemoved() all occur _after_ the event has occurred, and
the values that would possibly be useful are all gone throwning
IllegalStateExceptions left right and centre.

What gives ? Did the Servlet Spec people have some other use for
these Interfaces that I'm not smart enough to work out, or are
they only useful for printing "object added|removed|replaced"
without being able to actually obtain the object?

The specifications for 2.4 for javax.servlet.http.HttpSession
still say the same things as 2.3, and if implemented in the
same way don't appear to be useful at all....

Or is there some special magic that I'm not invoking the right
way ?

Help me, I'm confused ..

Cheers,
	-- jon

-- 
Jon Eaves <jo...@eaves.org>
http://www.eaves.org/jon/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Servlet/Session/Attribute Listeners not very useful ?

Posted by Jon Eaves <jo...@eaves.org>.
Jason Jonas - ATTBI wrote:
> Jon,

Hi Jason,

> 
> I've used the SessionListener interface once to write usage stats to a
> database when a user logs out explicitly or implicitly when the
> session times out. Haven't used it since and not too sure if I would
> again. However, the mechanism worked well enough to satisfy our
> requirement.

Yeah. That is also a use. Again, it's "anonymous" in that you can't
identify exactly what session expired, just that a session expired.

> 
> If you're trying to access your application objects bound into the
> session, perhaps you could wrap them in a single application object.
> While this is a kludge, it means the object references are readily
> available and would eliminate the IllegalStateExceptions you're
> encountering now. Just a thought.

It's more that I want to "clean up" some application wide data
when the session expires. I can't even work out how to map the
session that has just expired to anything useful either. If I
could get the "session id of the session that expired" then it
could store the information in application scope and use the ID
as a key.

 From my reading of the Servlet Specs and the API documentation it
appears that the intention of the expert group was along those
lines, but it doesn't seem to have carried through in the
implementation.

"SRV.10.7 Session Events
Listener classes provide the developer with a way of tracking sessions
within a web application. ... session became invalid because the
container timed out the session, or because a web component .. called
the invalidate() method. The disctinction may be determined indirectly
using listeners and the HTTPSession API methods"

and

javax.servlet.http.HttpSessionListener

public void sessionDestroyed(HttpSessionEvent se)

     Notification that a session was invalidated.

javax.servlet.http.HttpSessionEvent only has 1 method, to get the
session. Which at that time is invalid.

I might have to try some more obscure options like trying to use
an HttpSessionAttributeListener and the HttpSessionBindingEvent to
see if when a session is invalidated a BindingEvent is emitted.
I'm not thinking I'm going to be all that successful though.

I was half hoping that Craig might be able clarify after he's finished
with his Festive cheer ;-)

Cheers,
	-- jon

> 
> Jason
> 
> -----Original Message-----
> From: Jon Eaves [mailto:jon@eaves.org]
> Sent: Saturday, December 28, 2002 6:08 AM
> To: Tomcat Users List
> Subject: Servlet/Session/Attribute Listeners not very useful ?
> 
> Hi all,
> 
> Can anybody tell me what possible use these particular interfaces
> are ?
> 
> After thinking that they would be a good idea to use for web app
> session management enhancements (session timeout etc) it turns out
> that the invocations of valueUnbound(), sessionDestroyed(),
> attributeRemoved() all occur _after_ the event has occurred, and
> the values that would possibly be useful are all gone throwning
> IllegalStateExceptions left right and centre.
> 
> What gives ? Did the Servlet Spec people have some other use for
> these Interfaces that I'm not smart enough to work out, or are
> they only useful for printing "object added|removed|replaced"
> without being able to actually obtain the object?
> 
> The specifications for 2.4 for javax.servlet.http.HttpSession
> still say the same things as 2.3, and if implemented in the
> same way don't appear to be useful at all....
> 
> Or is there some special magic that I'm not invoking the right
> way ?
> 
> Help me, I'm confused ..
> 
> Cheers,
>         -- jon
> 
> --
> Jon Eaves <jo...@eaves.org>
> http://www.eaves.org/jon/
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 

-- 
Jon Eaves <jo...@eaves.org>
http://www.eaves.org/jon/



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Servlet/Session/Attribute Listeners not very useful ?

Posted by Jason Jonas - ATTBI <je...@attbi.com>.
Jon,

I've used the SessionListener interface once to write usage stats to a
database when a user logs out explicitly or implicitly when the
session times out. Haven't used it since and not too sure if I would
again. However, the mechanism worked well enough to satisfy our
requirement.

If you're trying to access your application objects bound into the
session, perhaps you could wrap them in a single application object.
While this is a kludge, it means the object references are readily
available and would eliminate the IllegalStateExceptions you're
encountering now. Just a thought.

Jason

-----Original Message-----
From: Jon Eaves [mailto:jon@eaves.org]
Sent: Saturday, December 28, 2002 6:08 AM
To: Tomcat Users List
Subject: Servlet/Session/Attribute Listeners not very useful ?

Hi all,

Can anybody tell me what possible use these particular interfaces
are ?

After thinking that they would be a good idea to use for web app
session management enhancements (session timeout etc) it turns out
that the invocations of valueUnbound(), sessionDestroyed(),
attributeRemoved() all occur _after_ the event has occurred, and
the values that would possibly be useful are all gone throwning
IllegalStateExceptions left right and centre.

What gives ? Did the Servlet Spec people have some other use for
these Interfaces that I'm not smart enough to work out, or are
they only useful for printing "object added|removed|replaced"
without being able to actually obtain the object?

The specifications for 2.4 for javax.servlet.http.HttpSession
still say the same things as 2.3, and if implemented in the
same way don't appear to be useful at all....

Or is there some special magic that I'm not invoking the right
way ?

Help me, I'm confused ..

Cheers,
        -- jon

--
Jon Eaves <jo...@eaves.org>
http://www.eaves.org/jon/


--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>