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

ServletRequestAttributeListener

 
Ranch Hand
Posts: 391
1
MySQL Database PHP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is my Servlet That I am hitting from browser


And This is the ServletRequestAttributeListener I have implemented



My output from apache tomcat log is this

org.apache.catalina.ASYNC_SUPPORTED : Attribute replaced . .Value true
name : Attribute added . .Value Mahtab
name : Attribute replaced . .Value Mahtab
name : Attribute removed .

I am not understanding this output.
I first called the setAttribute() method in the servlet , from where that first line in output comes.
Then I again call setAttribute on the same attribute to change its value but its showing Mahtab again it should have displayed Mahtab Alam.

setAttribute() calls attributeAdded() , does calling setAttribute() on the same attribute again calls attributeReplaced().
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I first called the setAttribute() method in the servlet , from where that first line in output comes.


From the name of it, org.apache.catalina.ASYNC_SUPPORTED looks like something Tomcat uses internally.

Then I again call setAttribute on the same attribute to change its value but its showing Mahtab again it should have displayed Mahtab Alam.


No, that's correct. See the javadocs of ServletContextAttributeEvent.getValue.

setAttribute() calls attributeAdded() , does calling setAttribute() on the same attribute again calls attributeReplaced().


Yes, that's the difference between "adding" and "replacing".
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic