org.springframework.web.util
Class WebAppRootListener
java.lang.Object
org.springframework.web.util.WebAppRootListener
- All Implemented Interfaces:
- EventListener, ServletContextListener
public class WebAppRootListener
- extends Object
- implements ServletContextListener
Listener that sets a system property to the web application root directory.
The key of the system property can be defined with the "webAppRootKey" init
parameter at the servlet context level (i.e. context-param in web.xml),
the default key is "webapp.root".
Can be used for toolkits that support substition with system properties
(i.e. System.getProperty values), like Log4J's "${key}" syntax within log
file locations.
Note: This listener should be placed before ContextLoaderListener in web.xml,
at least when used for Log4J. Log4jConfigListener sets the system property
implicitly, so there's no need for this listener in addition to it.
WARNING: Some containers like Tomcat do NOT keep system properties separate
per web app. You have to use unique "webAppRootKey" context-params per web app
then, to avoid clashes. Other containers like Resin do isolate each web app's
system properties: Here you can use the default key (i.e. no "webAppRootKey"
context-param at all) without worrying.
WARNING: The WAR file containing the web application needs to be expanded
to allow for setting the web app root system property. This is by default not
the case when a WAR file gets deployed to WebLogic, for example. Do not use
this listener in such an environment!
- Since:
- 18.04.2003
- Author:
- Juergen Hoeller
- See Also:
WebUtils.setWebAppRootSystemProperty(javax.servlet.ServletContext)
,
Log4jConfigListener
,
System.getProperty(java.lang.String)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WebAppRootListener
public WebAppRootListener()
contextInitialized
public void contextInitialized(ServletContextEvent event)
- Specified by:
contextInitialized
in interface ServletContextListener
contextDestroyed
public void contextDestroyed(ServletContextEvent event)
- Specified by:
contextDestroyed
in interface ServletContextListener
Copyright © 2002-2007 The Spring Framework.