On Wed, 12 Dec 2001 10:37, Kerry Todyruik wrote: > The approach I took was instead of having my main container residing in > one servlet, I made it a singleton. Then I created an InitServlet as I > saw somewhere for initizlizing Log4j and set this to load at startup by > including it in the webapps web.xml file. Just like Cocoon, I made the > InitServlet's init() and destroy() methods create and dispose of my main > container.
Instead of making it a singleton you may want to instead create the object normally and then place it in the ServletContext so that all servlets/jsps/etc in same web app can access it via looking it up in that. So you would havce something like MyComponent comp = ...; getServletContext().setAttribute( MyComponent.ROLE, comp ); and everywhere you need to use it do something like MyComponent comp = (MyComponent)getServletContext().getAttribute( MyComponent.ROLE ); This seems to be the "J2EE" way - whatever that means ;) That way it easy to add new services to the web application - just add a new servlet that creates a new componenet and retrieve the components from the ServletContext. -- Cheers, Pete ---------------------------------------------------------- Which is worse: Ignorance or Apathy? Who knows? Who cares? ---------------------------------------------------------- -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>