• Post Reply 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

[listener]Can someone tell me how many listeners should register in the DD?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, everybody:
There are eight listeners below:
--------------------
ServletContextListener
ServletContextAttributeListener
ServletRequestListener
ServletRequestAttributeListener
HttpSessionListener
HttpSessionAttributeListener
HttpSessionActivationListener
HttpSessionBindingListener
--------------------
Can you tell me what should register in the DD , and what not to?
 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
except HttpSessionActivationListener & HttpSessionBindingListener all others need to be registered in DD.

Vanniarajan
 
liny
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure???
According to HFS&J, HttpSessionActivationlistener must be configured in the DD!(See page 261)
I think the list below must be registered in the DD:
-------------------------------
ServletContextListener
ServletContextAttributeListener
HttpSessionListener
HttpSessionAttributeListener
HttpSessionActivationlistener
-------------------------------

The HttpSessionBindinglistener have no need to be configured in the DD.
But I don't know if the ServletRequestListener and the ServletRequestAttributeListener have to be configured in the DD!
Please tell me! Thanks!
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

every listener should be registered in DD except HttpSessionBindingListener.
 
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sorry to say i dont know the correct answer but i dont agree with Gabrie
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am fully agree with Gabriel Forro. Except HttpSessionBinidingListener you have to configure all other ( 7 other ) listener.
The configuration is like


<listener>
<listener-class>Fully qualified Class Name </listener-class>
</listener>



Thanks,
Pabak
 
liny
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pabak Nanda:
I am fully agree with Gabriel Forro. Except HttpSessionBinidingListener you have to configure all other ( 7 other ) listener.
The configuration is like


Thanks,
Pabak



Yes! That's right!
 
Saloon Keeper
Posts: 3931
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by liny liny:


Yes! That's right!



Nope,

Vanniarajan gave correct answer:

*HttpSessionActivationListener* AND *HttpSessionBindingListener* must not be registered in deployment descriptor, instead, they are implemented by session attribute objects.

Here is what specification says :

Containers must notify any session attributes implementing the
HttpSessionActivationListener during migration of a session. They must notify listeners of passivation prior to serialization of a session, and of activation after deserialization of a session.

So, you can see - attributes themselves implement this interface, attributes are listenes, not some special class, which configured via DD.

Also, refer these articles :

http://www.macromedia.com/support/jrun/ts/documents/tn18279.htm
http://e-docs.bea.com/wls/docs70/webapp/app_events.html

regards,
MZ
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*HttpSessionBindingListener* must not be registered in deployment descriptor, not *HttpSessionActivationListener*.


In HF servlet & JSP page 261 says this.
[ December 09, 2004: Message edited by: Romy Huang ]
 
Romy Huang
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These articles ref to servlet 2.3, now servlet 2.4

Originally posted by Mikalai Zaikin:

Also, refer these articles :

http://www.macromedia.com/support/jrun/ts/documents/tn18279.htm
http://e-docs.bea.com/wls/docs70/webapp/app_events.html

regards,
MZ


[ December 09, 2004: Message edited by: Romy Huang ]
 
Mikalai Zaikin
Saloon Keeper
Posts: 3931
43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, refer to JavaDoc API (J2EE 1.4):

http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionActivationListener.html


javax.servlet.http
Interface HttpSessionActivationListener

--------------------------------------------------------------------------------

public interface HttpSessionActivationListener
extends java.util.EventListener

Objects that are bound to a session may listen to container events notifying them that sessions will be passivated and that session will be activated. A container that migrates session between VMs or persists sessions is required to notify all attributes bound to sessions implementing HttpSessionActivationListener.


Since:
2.3



----------------------------------------------------------------------

Attributes which are bound to session are notified themselves, not special listeners.

----------------------------------------------------------------------

Please, take a look here:

http://java.sun.com/webservices/docs/1.2/tutorial/doc/Servlets11.html


Notifying Objects That Are Associated with a Session

Recall that your application can notify Web context and session listener objects of servlet life cycle events (Handling Servlet Life Cycle Events).

You can also notify objects of certain events related to their association with a session such as the following:

- When the object is added to or removed from a session. To receive this notification, your object must implement the javax.http.HttpSessionBindingListener interface.
- When the session to which the object is attached will be passivated or activated. A session will be passivated or activated when it is moved between virtual machines or saved to and restored from persistent storage. To receive this notification, your object must implement the javax.http.HttpSessionActivationListener interface.



P.S. I do not have a HF S & JSP book, so can not say on the page 261.

P.P.S. The purpose of this interface - to allow object (a.k.a. session attribute) store himself in some persistent storage (like DB, or serialize on disk) and later allow to restore himself. I don't see any sense to delegate this to different class (a.k.a. listener configured in DD) for the following reason:
1) (many listeners for each type) if you have 10 types of object potentially stored in session - you have to configure them in DD, whenever object of new type is added - change DD is necessary.
2) (single listener for all types) separate listener can not get access to object itself - note interface privides only 2 new methods with only session as argument. how separate listener supposed to store object in persistent place?

regards,
MZ
 
Romy Huang
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I check servlet special yesterday before I post that. now I wrie a progrom to test it. You are right. HttpSessionActivationListener don't need to register in DD. Thank you to clear that.
 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
check
http://e-docs.bea.com/wls/docs90/webapp/app_events.html#178631
 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that was an interesting thread... coz when i read HFSJ i thought that i need to register HttpSessionActivationListener in the DD.. but when i did some questions it seem the other way.. but i think i have cleared all my doubts now... so let me summarise what i learnt... and please point out if i'm wrong...

HttpSessionBindingListener Doest have to be registered in the DD but
HttpSessionActivationListener has to be registered if it is written as a seperate class without implementing it in the attribute class it self...

am i correct?
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think Charith Fernando is correct.

Please note that my conclusions are based on my own observations after reading the error page from O'reilly for HFSJ, contents in this thread and specifically HFSJ page 262.

The question of if a listener has to be entered in DD depends on the type of class implementing the listener.

First let us look at each of the listeners and see who can implement them (HSFJ Page 262):

HttpSessionListener ........Implemented by some class (other than attribute class).

HttpSessionAttributeListener...Implemented by some class (other than attribute class).

These two have to be entered in the DD - otherwise the container will not know of it existance.

HttpSessionBindingListener...Implemented by an Attribute class.

This does not have to be entered in DD - because any attribute added to a session, can be checked to see if it implements this listener interface and thus can be notified.

Now comes the interesting part:

HttpSessionActivationListener....Implemented by an Attribute class AND by some other class.

Now, my believe is that you will have to enter this listener in DD if it is implemented by "some other class" and does not have to be entered in DD if it is implemented only by Attribute classes.

Let us know if Charith and my observation is wrong.

Thanks.
 
I am going to test your electrical conductivity with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic