You can save some time by using the AppConfigContextListener in Java Web
Parts:
http://javawebparts.sourceforge.net/javadocs/javawebparts/listener/AppConfigContextListener.html
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.
Frank
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.
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.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]