How do i use Connection pool in JSP pages

Hey everyone,

I am using a connection pool in my web application. I am using DbConnectionBroker from Javaexchange.com. It has a class that creates a connection pool available for the servlets. I am trying to figure out that how to use connection pool within the JSP pages if I want to connect to the database. In the servlets i am using DBConnectionBroker pool = (DbConnectionBroker) getServletContext().getAttribute("dbPool") to get database connection. How Can i use this in JSP page to get a db connection.

Thanks

[550 byte] By [deep_3] at [2007-9-18]
# 1

If the reference to the connection pool is already stored as an ServletContex attribute, try:

<jsp:useBean id="dbPool" scope="application" class="com.javaexchange.dbConnectionBroker" />

.

.

<%

Connection con = dbPool.getConnection();

%>

GrayMan at 2007-7-4 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2
Whatever code works for servlet would work for JSP too. Use the code within scriptletsShubhrajit
shubhrajit_c at 2007-7-4 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 3
in jsp you can write your code as<%DBConnectionBroker pool = (DbConnectionBroker) getServletContext().getAttribute("dbPool");%>
aqb75 at 2007-7-4 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 4
I like what I see so far, but one thing is missing: Where in the code do you instantiate the connection pool and put it into the servlet context so that you may later use it?
wbracken at 2007-7-4 > top of java,Enterprise & Remote Computing,Web Tier APIs...