Package oracle.i18n.servlet.listener
Class ContextListener
- java.lang.Object
-
- oracle.i18n.servlet.listener.ContextListener
-
- All Implemented Interfaces:
EventListener,javax.servlet.ServletContextListener
public class ContextListener extends Object implements javax.servlet.ServletContextListener
TheContextListenerclass is the default context listener class that instantiates anApplicationContextobject.Register this class in
web.xmlso that it is called at startup of JSP/Java Servlet applications. For example:<listener> <listener-class>oracle.i18n.servlet.listener.ContextListener</listener-class> </listener>
If the application incorporates a database user schema containing a locale preference, a custom
ContextListenerclass may need to be used.The following example shows how to use the
contextInitializedandcontextDestroyedmethods in the context listener. Note that the constructor throws exceptions. For example:public void contextInitialized(ServletContextEvent event) { ... try { ServletContext context = event.getServletContext(); context.setAttribute( ApplicationContext.OBJECT_KEY, new ApplicationContext( context.getResourceAsStream(ApplicationContext.DEFAULT_GDKAPP), getClass().getClassLoader())); } catch (Exception e) { // handle exception ... } ... } ... public void contextDestroyed(ServletContextEvent event) { event.getServletContext().removeAttribute(ApplicationContext.OBJECT_KEY); }- Since:
- 10.1.0.2