Hi! I have in the path C:\WINDOWS\jbproject\WebDeveloperUno\webapps\ROOT\WEB-INF\classes\webdeveloperuno the below class: package webdeveloperuno; import javax.servlet.ServletContext; import javax.servlet.ServletContextAttributeEvent; import javax.servlet.ServletContextAttributeListener; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; public class ServletContextAttribListener implements ServletContextAttributeListener { //This method is invoked when an attribute //is added to the ServletContext object public void attributeAdded (ServletContextAttributeEvent scab) { System.out.println("An attribute was added to the " + "ServletContext object"); } //This method is invoked when an attribute //is removed from the ServletContext object public void attributeRemoved (ServletContextAttributeEvent scab) { System.out.println("An attribute was removed from " + "the ServletContext object"); } //This method is invoked when an attribute //is replaced in the ServletContext object public void attributeReplaced (ServletContextAttributeEvent scab) { System.out.println("An attribute was replaced in the " + "ServletContext object"); } } And I have also in the path C:\WINDOWS\jbproject\WebDeveloperUno\webapps\ROOT\WEB-INF the below file web.xml <web-app> <!-- Define application events listeners --> <listener> <listener-class> webdeveloperuno.ServletContextAttribListener </listener-class> </listener> <context-param> <param-name>param1</param-name> <param-value>value1</param-value> </context-param> <servlet> <servlet-name>atrib</servlet-name> <servlet-class>webdeveloperuno.ServletContextAttrib</servlet-class> </servlet> </web-app> I add attributes with the servlet atrib correctly but "An attribute was added to the ServletContext object" is not write in the console. Why??? Thank you in advance.
Madhav Lakkapragada
Ranch Hand
Joined: Jun 03, 2000
Posts: 5040
posted
0
Could you post the code for ServletContextAttrib also, if its not too much trouble...esp. the part of code where you add the attribute to the ServletContext. Also, with what URL are you accessing the webdeveloperuno.ServletContextAttrib servlet? regds. - satya