Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Reading a property file from WEB-INF/conf from a servlet

Posted on 2004-09-22
10
Medium Priority
?
259 Views
Last Modified: 2013-11-24
Hello All,

This is a pretty basic question. I want to know the standard way by which a properties file in the WEB-INF/conf can be retrieved by a servlet. That is the way in which it has the minimum dependencies with the appserver (i.e the directory in which the webapps is located, the make of appserver etc.)

I have used the init-param tags, but I had to give the full path (i.e C:\\Apache..) as the param value.

TYA,
QMS
0
Comment
Question by:sperin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12121662
Try

URLConnection conn  = new URLConnection("/WEB-INF/conf/x.properties");
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12121673
Thread.currentThread().getContextClassLoader().getResourceAsStream("/conf/x.properties");
0
 
LVL 92

Accepted Solution

by:
objects earned 150 total points
ID: 12121683
try:

Properties props = new Properties();
props.load(context.getResourceAsStream("/WEB-INF/conf/x.properties");
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 86

Expert Comment

by:CEHJ
ID: 12121709
Please tell us which work and which don't before accepting sperin
0
 
LVL 92

Expert Comment

by:objects
ID: 12121720
> Please tell us which work and which don't before accepting sperin

I think you're supposed to tell sperin what works :-D
0
 
LVL 92

Expert Comment

by:objects
ID: 12121756
Thanks sperin :)

Let me know if you have any further questions.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12121758
!?
0
 

Author Comment

by:sperin
ID: 12121805
Will tell you chaps about it. I was aware of a ServletContext object, so I too a wild guess and accepted the reply from objects. Now if that does'nt work, well my bad luck :)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12121849
LOL. Aside from rudely ignoring my request, you'd have thought from your point of view it might be just slightly useful to check the answers before making a choice.
0
 
LVL 18

Expert Comment

by:armoghan
ID: 12121869
:)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
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.
Suggested Courses

598 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