Link to home
Start Free TrialLog in
Avatar of sperin
sperin

asked on

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

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
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try

URLConnection conn  = new URLConnection("/WEB-INF/conf/x.properties");
Thread.currentThread().getContextClassLoader().getResourceAsStream("/conf/x.properties");
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Please tell us which work and which don't before accepting sperin
> Please tell us which work and which don't before accepting sperin

I think you're supposed to tell sperin what works :-D
Thanks sperin :)

Let me know if you have any further questions.
!?
Avatar of sperin
sperin

ASKER

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 :)
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.