Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Servlets and the fly likes opening a file in web-inf Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "opening a file in web-inf" Watch "opening a file in web-inf" New topic

opening a file in web-inf

Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
I'm trying to open a config file that's located in web-inf/config/config.xml and was wondering what the best way to do so is.

Is it possible to open this file using classloaders? Or can you simple just try to open a stream to /web-inf/config/config.xml in your war file?

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

It's WEB-INF, not web-inf.

[ July 31, 2008: Message edited by: Bear Bibeault ]

[Asking smart questions] [About Bear] [Books by Bear]
Johnny Gara
Ranch Hand

Joined: Mar 09, 2007
Posts: 43
ah, you are correct, thanks Bear

for completeness, the correct call would be

ServletContext.getResourceAsStream( "/WEB-INF/conf/config.xml");
I agree. Here's the link:
subject: opening a file in web-inf
jQuery in Action, 3rd edition