Solved

How to read a property from a properties file

Posted on 2007-04-03
2
190 Views
Last Modified: 2013-11-24
I have a Servlet deployed on Tomcat. In my servlet I want to read a property from a properties file which is inside WEB-INF directory.
Please tell me how to do it.
0
Comment
Question by:rea_19
2 Comments
 
LVL 14

Accepted Solution

by:
boonleng earned 75 total points
ID: 18842351
String path = getServletContext().getRealPath("/WEB-INF/filename.properties");

Properties properties = new Properties();
properties.load(new FileInputStream(new File(path)));
0
 
LVL 10

Assisted Solution

by:Jaax
Jaax earned 50 total points
ID: 18842363
You could also try :
InputStream is = getClass( ).getResourceAsStream("filename.ext");
Properties properties = new Properties(is);


0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question