You can save some time by using the AppConfigContextListener in Java Web Parts:

In it's simplest configuration it should take all of a few minutes to get it done, there are more advanced modes of operation if you need them.


P.S. - Someone else asked if a listener is better than a startup servlet of Struts plug-in... IMO, it's better than a plug-in because it's one less thing that is Struts-specific... Arguably it isn't any better than a startup servlet I suppose.

Wendy Smoak wrote:
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.

Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies

To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to