File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Bean for Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Bean for Servlets" Watch "Bean for Servlets" New topic

Bean for Servlets

SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
If I have a connection pool bean which is declared in 'application' scope, how can I make it availabe to servlet? I can get the connection using this bean but I don't have an idea to past the bean object to the servlets. Thanks a lot.
Marcos Maia
Ranch Hand

Joined: Jan 06, 2001
Posts: 977
You can import and instantiate the bean like you do in any other java class.
SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
The fact is, the bean is already instantiated in other jsp page, it manage the connection pool, my goal is to get a connection from this pool bean inside my servlet so i don't have to recreate another pool. If i instantiate another pool bean in my servlet, will i have two bean objects that hold a set of connection separately?
Vedprakash Pathak

Joined: Mar 06, 2001
Posts: 24
I guess your bean must be having a static getConnection method.. if not create one and use that method to get the connection from the bean.
Paul Richards

Joined: Jul 25, 2001
Posts: 19
If I understand correctly the bean that you have created with Application scope should be automatically available to your servlet via the servletContext.

hope this correct
I agree. Here's the link:
subject: Bean for Servlets
jQuery in Action, 3rd edition