This book on JSP's "Wedb development with Java Server Pages" by
Fields and Kolb which I highly recommend suggests creating a DB pool
like the following:

<%! static private DBConnectionPool pool = null;
         public void jspInit() {
              pool = (DBConnectionPool)
application.getAttribute("dbPool");
             if (pool == null) {
                    pool = DbConnectionPool.getPool(...);
                    application.setAttribute("dbPool", pool);
            }
        }
    } %>

    Similarly, I'd like to shutdown the pool when Tomcat is shutdown:

<%! public void jspDestroy() {
            if (pool != null)
                pool.destroy();
                application.removeAttribute("dbPool");
            }
        } %>

    However, when I try something like this I get "undefinded variable:
application" Then I look at the java file Tomcat generates and it looks
like all the implicit objects get initialized in the service() methods,
so that it has no understanding of the variables set in the jspInit()
function.

    How does one go about creating a single instance of an application
scoped object that can be initialized and shutdown?

    Thanks very much, Jason



--
Jason Novotny               [EMAIL PROTECTED]
Home: (510) 704-9917        Work: (510) 486-8662
NERSC Distributed Computing http://www-didc.lbl.gov




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

Reply via email to