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.

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:

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]

Reply via email to