If I set a database connection in a bean with scope application how do I manage closing the connection and pooling the connection? I'm using Record Level Access on an AS400 DB2 database and I would much rather keep the logic in the bean than use the servlet to manage the connections.

Thanks,

Ben Dudley

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

(3) Application Lifetime

Use this technique to pass beans that are relevant to all servlets and JSP pages in a particular app, for all users. For example, I use this to make a JDBC connection pool object available to the various servlets and JSP pages in my apps. This bean will disappear when the servlet engine is shut down, or when you remove it.

SERVLET:
    getServletContext().setAttribute("theBean", myBean);
JSP PAGE:
    <jsp:useBean id="theBean" scope="application" class="..." />
--------------------------------------------------------------------------------------------------------------------------------------------

Reply via email to