From: "C.F. Scheidecker Antunes" <[EMAIL PROTECTED]>
I would like to have a bean with a data structure that gets populated when
the application starts and then this bean is available to the entire
application.
Use a ServletContextListener, which will be notified when the context starts
and stops.
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContextListener.html
public class MyContextListener implements ServletContextListener {
public void contextInitialized( ServletContextEvent event ) {
ServletContext context = event.getServletContext();
// create your bean by reading from the database
context.setAttribute( "beanName" , bean );
}
}
In web.xml:
<listener>
<listener-class>edu.example.MyContextListener</listener-class>
</listener>
Now you can use context.getAttribute( "beanName"); in Java code, or
expressions such as ${beanName.propName} to get access to it.
--
Wendy Smoak
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]