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.
Hi, In my web application, I get db username and password from the web.xml file under the servletcontext directory. In its web.xml file, several init-params are declared. Now, I want to distribute this application in war format but web.xml file will go into that archive file and cannot be changed after archived.
Is there any way that I can get this info from outside the .war file? If so, can you give an example how to get it within the sevlet? Thank you.
An alternative is to use a DataSource with a set name (if this is for a database connection) or use JNDI with a set name. Basically you want a method to get a value based on a key while not tying that value to an archive or format that should not be changed. An external Properties file, a DataSource configured at the app/web server level with a set name of a JNDI entry with a set name are all valid options.
author & internet detective