This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes web application - property file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "web application - property file" Watch "web application - property file" New topic
Author

web application - property file

Ann Kanu
Ranch Hand

Joined: Feb 01, 2004
Posts: 30
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.
Jayson Falkner
Author
Ranch Hand

Joined: May 07, 2001
Posts: 57
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 />jayson@jspinsider.com<br />Author of <a href="http://www.jspbook.com" target="_blank" rel="nofollow">Servlets and JavaServer Pages; the J2EE Web Tier</a>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: web application - property file
 
Similar Threads
directory structure questions...
Servlet config in servlets
How to pass a dynamic parameter in struts-config.xml?
Loading Configurable Parameters in a J2EE App
reading .properties file