You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by tomcat t tomcat <ky...@mailcity.com> on 2000/05/24 01:43:42 UTC

two beans in jsp page

I am using two different beans in my jsp page.
one bean is in application scope which act as a connection pool. and the other bean want to get connection from the pool.

how can the bean get the reference of the pool bean?

thanks


Get your FREE Email at http://mailcity.lycos.com
Get your PERSONALIZED START PAGE at http://my.lycos.com

Re: two beans in jsp page

Posted by Derek DeMoro <dd...@home.com>.
Use the instance name as the reference.


----- Original Message -----
From: "tomcat t tomcat" <ky...@mailcity.com>
To: <to...@jakarta.apache.org>
Sent: Tuesday, May 23, 2000 4:43 PM
Subject: two beans in jsp page


> I am using two different beans in my jsp page.
> one bean is in application scope which act as a connection pool. and the
other bean want to get connection from the pool.
>
> how can the bean get the reference of the pool bean?
>
> thanks
>
>
> Get your FREE Email at http://mailcity.lycos.com
> Get your PERSONALIZED START PAGE at http://my.lycos.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>


Re: two beans in jsp page

Posted by Jon Stevens <jo...@latchkey.com>.
on 5/23/2000 4:43 PM, tomcat t tomcat at kyluitomcat@mailcity.com wrote:

> I am using two different beans in my jsp page.
> one bean is in application scope which act as a connection pool. and the other
> bean want to get connection from the pool.
> 
> how can the bean get the reference of the pool bean?
> 
> thanks

I would use a singleton based connection pool so that you can get a DB
connection from anywhere in your code at any time...turbine has one...

here is what the code ends up looking like...

try 
{ 
    // get a connection to the db
    DBConnection db = DBBroker.getInstance().getConnection();
    Connection connection = db.getConnection();

    // write your JDBC code here
} 
finally 
{ 
    DBBroker.getInstance().releaseConnection(db);
}

very simple.

<http://java.apache.org/turbine/>

-jon