Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Filter vs Listener to keep track of session instances

 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


Which makes the most sense for your scenario?



hmm..good question:-)

Look at my topic https://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
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Bartender
Posts: 4179
22
IntelliJ IDE Python Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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