and HttpSessionBindingListener, do not be configured in DD since the Container calls the event handling (valueBound() & valueUnbound()) when an intance of certain class is added to or removed from a session.
almost the same words from HFSJ.. well it is the SAME.
From NickyEng
Diploma in Computer Studies
SCJP 1.4
SCWCD 1.4
Formula 1 app by Maxis (Playbook)
I agree with you that HttpSessionBindingListener and HttpSessionActivationListener do not need to be declared in DD. However, my conclusion is based on my own logical guess. I just want to know which part of the spec does have a clear definition of this requirement?
Will Lee
Ranch Hand
Joined: Mar 16, 2005
Posts: 58
posted
0
check J2ee API (or servlet API, or maybe the spec.), There's description for HttpSessionListener: To be notified, the class of this type must be registered in DD.
and HFSJ only emphasized Binding and ActivationListener don't need to be, so I guess HttpSessionAttrListener may need this step.
Hi, according to HFSJ(Pg:254), HttpSessionActivationListener also need to be registered in DD. On what basis you guys are saying that it is not needed to register? But HFSJ book doesnt talk much on other types of listerners also. My question is request and context listeners need to be registerd in DD or not? I am guessing except HttpSessionBindingListner, all other listeners must be registered in DD.
Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Edmund Yong
Ranch Hand
Joined: Nov 16, 2003
Posts: 164
posted
0
according to HFSJ(Pg:254), HttpSessionActivationListener also need to be registered in DD. On what basis you guys are saying that it is not needed to register?
A trick to remember which event listeners to register in the DD :
The listeners can be classified in 2 categories:
1. Those that are interested in all events of one type(e.g. HttpSessionListener (interested in ALL Http session creation and destruction events), HttpSessionAttributeListener(interested in all session attribute events - any attribute added / removed / replaced), and all the listeners for ServletContext and ServletRequest.
The container creates one instance of each of these listeners.
2. Those that are interested only in specific events of one type. (there are 2 listeners of this type - HttpSessionBindingListener (interested in knowing when it is itself bound / unbound to a HttpSession) and HttpSessionActivationListener(interested in knowing when only the session it is bound to is activated or passivated, so that it can prepare itself for activation / passivation)
We create the instances of these listeners and set them as attributes in specific http sessions.
The first type of listeners are configured in the DD - as their methods are ALWAYS called when the event occurs.
The second type of listeners are not configured in the DD.
On page 262 in HFSJ, it is mentioned that HttpSessionActivationListener interface may usually be implemented by an attribute class or some other class. I think this is not correct - HttpSessionActivation should always be implemented by an attribute class. - Gouri [ September 27, 2005: Message edited by: Gouri Bargi ]
Will Lee
Ranch Hand
Joined: Mar 16, 2005
Posts: 58
posted
0
Yes, I agree. I think the HSActivationListener should not be implemented by "other" class.
Thanks for giving such detail explaination. I guess an easy way to remember is: All listener that are implemented by attribute obj. should NOT be registered in DD. They are HSBindingListener and HSActivationListener. For everything else (servlet context and request, other HttpSession listener), you must declare in DD. The order of them in DD matters.