File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet config in servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet config in servlets" Watch "Servlet config in servlets" New topic
Author

Servlet config in servlets

Srishti Deepa
Greenhorn

Joined: Jun 14, 2006
Posts: 9
Hi,
I want to read the properties file which is in /WEB-INF/classes of my application. I am using tomcat.I have written a servlet. I want to read the properties file from the servlet. How can I do that. If I want to use the init(ServletConfig config) method for reading the properties file using servlet context how I can do it. Do I have to configure the servlet config in web.xml file.
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

You can use this method to get your properties file from the WAR. However a properties file is not meant to be deployed along with a WAR file. A properties file should be placed outside the project location where it can be accessed by the application. Ideally you should be able to simply edit the file, and restart the application so that it can absorb the new changes. It is also possible to code in such a way that editing the file alone is sufficient. The advantage being that you dont have to build the WAR file again.


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Deepak Bala wrote:However a properties file is not meant to be deployed along with a WAR file.

That's highly dependent on the property file in question--there are all sorts of reasons why a property file might be deployed inside an application.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet config in servlets