Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Servlets ServletRequestAttributeListener

Related Tutorials


 
 

Share on Google+Share on Google+

ServletRequestAttributeListener

Advertisement
This listener is used when we want to know when a attribute has been added in a request, when a attribute has been removed and when it is replaced by another attribute.

ServletRequestAttributeListener

     

This listener is used when we want to know when a attribute has been added in a request, when a attribute has been removed and when it is replaced by another attribute. We can also say that this attribute is  used when the developer is interested to be notified when the request attribute changes. Now you may be wondering what is an attribute. An attribute is an object set or you can simply say that it is name/value pair where the name refers to a String and a value refers to the Object.

javax.servlet.ServletRequestAttributeListener interface has following methods:

  1. attributeAdded(ServletRequestAttributeEvent event): It notifies whenever a new  attribute is added to the servlet request.
  2. attributeRemoved(ServletRequestAttributeEvent event): It notifies whenever the attribute is removed from the servlet request.
  3. attributeReplaced(ServletRequestAttributeEvent event): It notifies whenever the attribute gets replaced on the servlet request.

In the above methods you can see that we have used ServletRequestAttributeEvent class as a parameter to the above methods. This class is a event class which is used for notifications when the changes are made to the attributes of ServletRequest in an application.

The class ServletRequestAttributeEvent has two methods:

  1. getName() : This method returns the name of the attribute that has been changed on the ServletRequest.
  2. getValue(): This method will return the value of the attribute that has been added, removed or replaced by other attribute.


Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Discuss: ServletRequestAttributeListener  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com