Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about listener

 
Patel Brijesh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can any one help me to answer which the listener is/are used and event object used for this situation.and which of the class will implement it ie attribute or other class
Q1:
An attribute wants to know when it has been moved from one session to another vm?
Q2:An attribute wants to know when it has been replaced in a session.?
Q3: when you want to be notified when anything is bound to session ??

can any one tell me the answer please.......
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is simple and will be written straight in any book /website...
Try looking for it yourself...
 
Poonam Kohli
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Patel Brijesh wrote:Q1: An attribute wants to know when it has been moved from one session to another vm?

HttpSessionActivationListener, HttpSessionEvent, Attribute

Patel Brijesh wrote:Q2:An attribute wants to know when it has been replaced in a session.?

HttpSessionBindingListener, HttpSessionBindingEvent, Attribute

Patel Brijesh wrote:Q3: when you want to be notified when anything is bound to session ??

HttpSessionAttributeListener, HttpSessionBindingEvent, Some other class

No question is bad.. However, spoon feeding is bad.. You could have read this in any book. Thanks for letting me practice with Listeners. I hope my answers are correct here.
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q2:An attribute wants to know when it has been replaced in a session.?
HttpSessionAttributeListener, HttpSessionBindingEvent,


Q3 when you want to be notified when anything is bound to session ??
HttpSessionBindingListener, HttpSessionBindingEvent,

 
Poonam Kohli
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nabila Mohammad wrote:Q2:An attribute wants to know when it has been replaced in a session.?
HttpSessionAttributeListener, HttpSessionBindingEvent,


Q3 when you want to be notified when anything is bound to session ??
HttpSessionBindingListener, HttpSessionBindingEvent,



Dont you think you have flipped them around?
 
Nabila Mohammad
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HttpSessionAttributeListener is for session attributes that are added, removied or replaced
Its has methods:
attributeAdded()
attributeRemoved()
attributeReplaced()


HttpSessionBindingListener is for sessions attribute that are bound to the session
It has methods :
valueBound()
valueUnbound()
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi patel
just curious to know ..where did you get this question from?
 
Poonam Kohli
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vani venkat wrote:hi patel
just curious to know ..where did you get this question from?


Seems he is copying the question from HFSJ worksheet in chapter 6.

I just finished that chapter this afternoon and I know it is there.
 
vani venkat
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q3: when you want to be notified when anything is bound to session ??



ans is httpSessionAttributeListener for this question.

Nabila, httpSessionBindingListener will notify an "object" when attributes of that type are added to session. since in this question, it doesnot specify one single object rather wants to be notfied when anything is bound to session, i think httpSessionAttributeListener is appropriate in this situation.

I am not sure about Q2 as it talks about replaced and the notification is to be sent to Object itself. can some one explain this.
Poonam, thanks for the info. i am abit skeptic about wordings of Q2.
 
Patel Brijesh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nabila Mohammad wrote:Q2:An attribute wants to know when it has been replaced in a session.?
HttpSessionAttributeListener, HttpSessionBindingEvent,


Q3 when you want to be notified when anything is bound to session ??
HttpSessionBindingListener, HttpSessionBindingEvent,


For Q2 HttpSessionListnener implementing class will not be Attribute class
For Q3 HttpSessionBindingListener will be implemented by Attribute class so how would we know?

Thanks, for your help....
will allways looking forward for your and javaRanch memeber's help in Difficult situation.
 
Patel Brijesh
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Poonam Dhillon wrote:
Patel Brijesh wrote:Q1: An attribute wants to know when it has been moved from one session to another vm?

HttpSessionActivationListener, HttpSessionEvent, Attribute

Patel Brijesh wrote:Q2:An attribute wants to know when it has been replaced in a session.?

HttpSessionBindingListener, HttpSessionBindingEvent, Attribute

Patel Brijesh wrote:Q3: when you want to be notified when anything is bound to session ??

HttpSessionAttributeListener, HttpSessionBindingEvent, Some other class

No question is bad.. However, spoon feeding is bad.. You could have read this in any book. Thanks for letting me practice with Listeners. I hope my answers are correct here.


are you sure about these answer to be correct or your answer after this connversation ie . in second conversation is correct. it seems that your first conversation's answers are correct .. do let me know.. I have read same book but not able to work on common sense as it cannot be used for answer important in exam ,better to be clear about answer rather than depending on Guesses.

Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic