File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes connection in ContextAttribute Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "connection in ContextAttribute" Watch "connection in ContextAttribute" New topic

connection in ContextAttribute


Joined: Jun 22, 2006
Posts: 8
iam getting connection to DB in Listener class and setting it as a Context Attribute.this class is called when deploying the application.
i am not using connection pooling.
thic connection obj iam using in alll jsp's & Servlets.
Is it a good practice to do that.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

"heidi psl", please take the time to choose the appropriate forum for you questions. 4 out of 5 of your previous posts had to be moved to different forums, This is clearly a Servlets question and should be asked in the Servlets forum.

I've moved this topic there.

[Asking smart questions] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

Also, you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

Be aware that accounts with invalid display names are removed.

JavaRanch Sheriff
Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Originally posted by heidi psl:
Is it a good practice to do that.

Search this forum with keywords "connection pooling" and you will find many, lengthy, drawn out discussions on the subject.

Please fix your name so you can remain with us.
[ June 24, 2006: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Chintan Rajyaguru
Ranch Hand

Joined: Aug 19, 2001
Posts: 341
Well, the question should be why aren't you using connection pooling? Most database driver implementations support it. You can define a data source for your web application and use it for database interaction. - Coming soon!
Nikhil Goel
Ranch Hand

Joined: Jul 11, 2003
Posts: 32

you need to use Connection pooling reason being in a web based application you can have n number of users accessing the app hence context is not a nice idea.
Context in any application servers, applications are used for the properties,values that remain same through out the life of an application and also applications interact with servers through context .

I agree. Here's the link:
subject: connection in ContextAttribute
It's not a secret anymore!