This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Please use code tags when posting code.
As already suggested, a servlet is not the right place of having utility methods. A servlet has to undergo a lifecycle managed by the servlet container which determines the information that it has.
Thanks and Regards
Joined: Oct 20, 2010
Now I use a Java class which is using the ServletContext.
In the contructor I set up the Properties, and in a separate method I code "con = DriverManager.getConnection(databaseName, userName, passWord);".
After creating a Connection (con), I use context.setAttribute to store the con variable.
It seems to work now. The ServletContext is still the same as yesterday, and still alive!
But if you have better suggestions, I love to hear it!