I am trying to read all the properties from an application property file into a java class which is part of a web application deployed on weblogic. I am currently hardcoding the location of the property file which holds parameters necessary for my application like email id of the application administrator etc. I use these properties in some of my classes which implement business logic. If I am using parameters in a servlet, I can get it via the init() method from web.xml. But how do I retrieve parameters which are not used in a servlet without hardcoding the location of the file which holds these parameters. Is there a better way to obtain the location of this property file.
Everything in your web application should be able to get at the ServletContext object, so you can always try to encode information in the web.xml parameters. Or alternatively, you can use the ServletContext object to resolve the location of a file in your web application, e.g. your property file. However, if you want to use regular Java property files you can as well. Simply put the '.properties' file in your WEB-INF/classes directory of your web application. It will then be in the class path of your application.
Jayson Falkner<br />email@example.com<br />Author of <a href="http://www.jspbook.com" target="_blank" rel="nofollow">Servlets and JavaServer Pages; the J2EE Web Tier</a>