Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

ServletRequestAttributeListener  RSS feed

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • 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().
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • 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".
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!