Listeners and Events

There are 8 Listeners to remember. We know there are attributes in 4 scopes because we know how to Pick the Right Scope Automatically, but you can’t listen to Page attributes, it doesn’t make sense, so that leaves us with RSA; Request, Session and Application. These tally with the objects:

  • ServletRequest
  • HttpSession
  • ServletContext
There is a Listener for each of these objects for lifecycle events, and for attribute events, so that gives us 6 of the Listener Interfaces:
  • ServletRequest[Attribute]Listener
  • HttpSession[Attribute]Listener
  • ServletContext[Attribute]Listener
HttpSession gets the 2 extra interfaces:
  • HttpSessionBindingListener – Attribute objects implement this if they themselves want to know whenthey are [un]bound
  • HttpSessionActivationListener – Listen here to have a nose when the session is gallivanting around

Events

There are just 6 events, one for each lifecycle event:

  • ServletRequestEvent
  • HttpSessionEvent
  • ServletContextEvent
and one for each attribute-related event:
  • ServletRequestAttributeEvent
  • HttpSessionBindingEvent – (It’s easy to remember this black sheep because its initials rhyme with the worlds local bank HSBE)
  • ServletContextAttributeEvent

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code lang=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" extra="">