On 19 Mar 2001, Gary Lawrence Murphy wrote:

> 
> I know I can initialize a servlet when tomcat boots by entering it
> into the web.xml file, but is there an elegant way to initialze an
> application-scoped jsp:useBean?  Right now, I just hit the page with
> Lynx when the tomcat script boots, but that's pretty kludgy.
> 

An application-scoped bean (from the JSP perspective) is just a servlet
context attribute (from the servlet perspective).  So, in the
init() method of your <load-on-startup> servlet, you can do things like:

        ConnectionPool myPool = new ConnectionPool(...);
        getServletContext().setAttribute("pool", myPool);

and the connection pool will be initialized and available to JSP pages
under application scope.

> -- 
> Gary Lawrence Murphy <[EMAIL PROTECTED]> TeleDynamics Communications Inc
> Business Innovations Through Open Source Systems: http://www.teledyn.com
> "Computers are useless.  They can only give you answers."(Pablo Picasso)
> 
> 

Craig McClanahan


Reply via email to