|
Oracle® Globalization Development Kit Java API Reference 10g Release 1(10.1) B10971-01 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--oracle.i18n.servlet.listener.ContextListener
ContextListener is the default context listener class that instantiates an ApplicationContext object.
Register this class in web.xml so that it is called at the start up of JSP/Java Servlet applications. Here is the example:
<listener> <listener-class>oracle.i18n.servlet.listener.ContextListener</listener-class> </listener>
If the application incorporates database user schema containing a locale preference, a custom ContextListener may need to be used.
The following example shows how to use contextInitialized and contextDestroyed methods in the context listener. Note that the constructor throws exceptions.
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);
}
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface javax.servlet.ServletContextListener |
contextDestroyed, contextInitialized |
|
Oracle® Globalization Development Kit Java API Reference 10g Release 1(10.1) B10971-01 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||