Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Listener Class Configuration

 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I want to know which listener class needs no configuration in DD, In my understanding from HFSJ is " we should not configure HttpSessionBinding Listener in DD", please correct if i am wrong.

I have another doubt, in HFSJ PgNo 262 it is given as
HttpSessionListener,HttpSessionAttributeListener are usually implemented by An Attribute class. Can any one clear what it means.

Thank you
 
Rohitt Vermaa
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need not configure the HttpSessionBindingListener and HttpSessionAttributeListener in the DD.

The Listerners are implemented in a seperate class. But we can implement the HttpSessionAttributeListener in the attribute class itself. For example there is a class Employee and you want to perform some action when the attribute is added or removed from the session. In this case you can implement the HttpSessionAttributeListener in the Employee class itself.

public class Employee implements HttpSessionAttributeListener {
private String name;
// setter and getter method for name
public void attributeAdded(HttpSessionBindingEvent sbe){ }
// for attribute remove and replaced.
}
 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rohitt for your reply.. Now iam clear with Listener
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rohit Varma, What are you saying?


The Listerners are implemented in a seperate class. But we can implement the HttpSessionAttributeListener in the attribute class itself. For example there is a class Employee and you want to perform some action when the attribute is added or removed from the session. In this case you can implement the HttpSessionAttributeListener in the Employee class itself.

public class Employee implements HttpSessionAttributeListener {
private String name;
// setter and getter method for name
public void attributeAdded(HttpSessionBindingEvent sbe){ }
// for attribute remove and replaced.
}


If an attribute(object) wants to know when it is added or removed to and from a session that attribute class must implement HttpSessionBindingListener not HttpSessionAttributeListener.

HttpSessionAttributeListener will execute whenever any attribute in the appication will added or removed to a session.
 
vinod balaji
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do we need to configure httpsessionactivationlistener in DD. if then,is it mandatory or option
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpSessionBindingListener listener is the only listener that you DO NOT have to configure in the DD.
 
Elan Ram
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey there is one more listener that we dont need to register in the DD. Check it out.
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no. you don't need to mention in DD for HttpSessionActivationListener.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know Elan. If you know please tell me and give a brief explanation too.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Prabhu Venkatachalam, in HFSJ(page 261)(BANG!) says

HttpSessionActivationListener must be configured in the DD
 
Rohitt Vermaa
Ranch Hand
Posts: 232
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes sreeraj i was wrong. It should be HttpSessionBindingListener.
HttpSessionAttributeListener need not be configured in the DD. Please go through this.
http://www.coderanch.com/t/170002/java-Web-Component-SCWCD/certification/HttpSessionActivationListener-configured-DD
 
Vinay Kumar chowdary
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
U can check the below link for more information on this topic

http://faq.javaranch.com/view?DeclaringListeners
 
Elan Ram
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No need to declare both HttpSessionActivationListener & HttpSessionBindingListener. What ever the Objects implenting any of these listener, will be notified automatically.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am still confused about why Bert Bates,Kathey Sierra and Bryan Basham not responding about this.
HFSJ says HttpSessionActivationLstener must be configured in the DD.But ohter books says configuration of HttpSessionActivationListener in the DD is not necessary.
Its not an errata of HFSJ book.
 
Sreeraj G Harilal
Ranch Hand
Posts: 310
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorryyyy i got. Its an 'Errata'.

it says


{261} Bang box:
The Bang! box on pg 261 is erroneous and should be dropped altogther.



Sorry everybody. Actually i always forgot to refer errata page before replying any topic.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic