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

11 EL Implicit Variables

All the EL implicit variables are Maps except for pageContext.

To remember the attribute-holding scope objects, just remember to Pick the Right Scope Automatically and stick the word “Scope” on the end:

  • pageScope
  • requestScope
  • sessionScope
  • applicationScope

Then you have 4 param and header objects of the form : (param|header)[Values]

  • param
  • paramValues
  • header
  • headerValues
Then I just remember the last 3:
  • cookie
  • initParam
  • pageContext (not a Map, it’s the JavaBean)

Captain Pan PreVents Captain Hook

This is (a rubbish one) just to help me remember the DD tags:

<context-param>

<param-name>n</param-name>

<param-value>v</param-value>

</context-param>

Whereas Servlet params are “in-it”:

<servlet>

<init-param>

<param-name>n</param-name>

<param-value>v</param-value>

</init-param>

</servlet

Direct a Film about Petal Ink

I’ve made a timelapse film of some daffodils blossoming but I really should do another one of a rose with its stem split into two different bottles of ink.

Not a very interesting post, it’s just another think I need top remember from this book for my exam.

Direct a film about PeTaL INk
Boils down to:
Jsp Directives are Page, Taglib and Include

Tie up the JSP implicit variables with SCRAPROPE

Use the acronym SCRAPROPE to remember the JSP implicit variables:

session
config
request
application
pageContext
response
out
page
exception

I should really credit Russ for coming up with the acronym. I think my attempts, SCORP RAPE and SPORE CRAP, weren’t as catchy.

Pick the Right Scope Automatically

As I previously metioned, I’m taking the SCWCD exam tomorrow. When trying to cram for any exam I like to make up short poems, acronyms or just random chains of though. For example, I know the difference between Mitosis and Meiosis because Meiosis begins with “Meow” which is what cats do and they have four legs… anyway…

My first thing to remember is that a JspContext has a findAttribute method that I can use to Pick the Right Scope Automatically.

The acroynym, PRSA, is the order scopes are searched for attributes: Page, Request, Session, Application. You know that the S stands for Session because you can’t put attributes in a servlet. This also allows you to remember which objects can have attributes.