I have a listener class that implemets servletContextListener. The contextInitialized method sets an attribute and the listener is configured properly in my web.xml file. My doubt is... if i use a System.out.println statement in the
java source will the output appear on the web container's console ? Here are the files
web.xml:
<listener>
<listener-class>myListener</listener-class>
</listener>
This is placed properly inside web-app tag.
myListener.java
import javax.servlet.*;
class myListener implements ServletContextListener
{
public void contextInitialized ( ServletContextEvent event )
{
System.out.println("Initializing Context...");
ServletContext sc = event.getServletContext();
sc.setAttribute( "data" , sc.getInitParameter("bull") );
}
public void contextDestroyed( ServletContextEvent event )
{}
}
When i try to get the attribute i get a null value so i thought may be the listener is not running as yet. I cannot find the
String Initializing Context... anywhere on my console. Does this mean the Listener is not running at all ? Why is it not detecting when my context is initialized ? Any ideas ?