Author
Filter vs Listener to keep track of session instances
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
posted Sep 05, 2008 09:46:00
0
When do I need Filter and when, Listener? In http://www.jguru.com/faq/view.jsp?EID=1063899 it is said, to keep track of all session-instances, it s better to do that with filter than with listener (such as HTTPSessionListener). Any suggestions?
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
posted Sep 05, 2008 09:52:00
0
When do you need the info? A listener will fire when the event occurs. A filter is executed when a request whose URL matches its mapping is invoked. Which makes the most sense for your scenario?
[Smart Questions ] [JSP FAQ ] [Books by Bear ] [Bear's FrontMan ] [About Bear ]
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
posted Sep 05, 2008 10:20:00
0
Which makes the most sense for your scenario?
hmm..good question:-) Look at my topic http://www.coderanch.com/t/321300/EJB-JEE/java/destroy-sessionContext-EJB . I want to get the session-instance when it s created by the user. I have solved this via an HTTPSessionListener storing all sessions in a map in the application-scope. But how can I delete a particular Session via this listener? Do I need the HTTPSessionEvent for that? Should I do that with the HTTPAttributeListener? Or with HttpSessionBindingEvent or HttpSessionBindingListener ? I have no clue how to retrieve and delete a particular session. With session.invalidate() only the actual session will be destroyed. I need something like the deprecated HttpSessionContext in which I can get a particular ID and delete it. Any Ideas?
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56168
posted Sep 05, 2008 10:24:00
0
Well that appears to be a completely different question than "when do I used filters vs. listeners?" I'd recommend changing the topic title accordingly.
nimo frey
Ranch Hand
Joined: Jun 28, 2008
Posts: 580
posted Sep 05, 2008 10:36:00
0
I d guessed that I can achieve this scenario with filters..it was not clear. Okay it seems it s better to use listeners. no ideas?
Steve Luke
Bartender
Joined: Jan 28, 2003
Posts: 3026
posted Sep 05, 2008 12:47:00
0
I am keeping the conversation in your other thread where it is more appropriate... no need to split the conversation.
Steve
I agree. Here's the link: jrebel
subject: Filter vs Listener to keep track of session instances