Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <listener>
- <listener-class>appobj.MyApplicationContextListener</listener-class>
- </listener>
- public class MyApplicationContextListener implements ServletContextListener {
- private static final String FOO = "foo";
- public void contextInitialized(ServletContextEvent event) {
- MyObject myObject = new MyObject();
- event.getServletContext().setAttribute(FOO, myObject);
- }
- public void contextDestroyed(ServletContextEvent event) {
- MyObject myObject = (MyObject) event.getServletContext().getAttribute(
- FOO);
- try {
- event.getServletContext().removeAttribute(FOO);
- } finally {
- myObject.dispose();
- }
- }
- }
- <f:view>
- <h:outputText value="#{applicationScope.foo.value}" />
- <h:outputText value="#{foo.value}" />
- </f:view>
- FacesContext.getCurrentInstance()
- .getExternalContext().getApplicationMap().get("foo");
Add Comment
Please, Sign In to add comment