File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
    Bookmark Topic Watch Topic
  • New Topic

Filter vs Listener to keep track of session instances

 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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?
 
nimo frey
Ranch Hand
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator

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
Pie
Posts: 64182
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Posts: 580
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
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
Pie
Posts: 4181
21
IntelliJ IDE Java Python
  • 0
  • Mark post as helpful
  • send pies
  • Report post to moderator
I am keeping the conversation in your other thread where it is more appropriate... no need to split the conversation.
 
    Bookmark Topic Watch Topic
  • New Topic