Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reading from war file

24 views
Skip to first unread message

Kumar

unread,
Feb 26, 2003, 1:30:20 AM2/26/03
to

Hi Guys,

We are facing few problems as regards to reading configuration file (say for e.g.
app.xml) which is inside the war file.
We have our configuration file inside the web-inf/classes folder inside the war
file.
We need to locate the file and use java.io classes to read it as well.
Question is :
When we use this.getClass().getResource("/WEB-INF/classes") method to locate ,
it returns the URL as
zip:<path of the war file>!<location inside the war file>
How should we go ahead and read the specific file using java.io classes ?

Any help on this is highly appreciated ........

Thanks,
Kumar

Xiang Rao

unread,
Feb 26, 2003, 12:14:59 PM2/26/03
to

Assume your config file is /WEB-INF/classes/config_file, try either
ServletContext.getResourceAsStream("/WEB-INF/classes/config_file")
or
this.getClass().getResourceAsStream("config_file")

With the method you use, you need use java.util.zip package for further processing
to locate the entry you need.

Mark Griffith

unread,
Feb 26, 2003, 12:05:52 PM2/26/03
to
If

WEB-INF/classes/app.xml

then do:

getClass().getResource("app.xml")

Consider using

http://java.sun.com/products/jdk/1.2/docs/api/java/lang/Thread.html#getConte
xtClassLoader()

Cheers
mbg
"Kumar" <kkr...@hss.hns.com> wrote in message
news:3e5c...@newsgroups.bea.com...

Thomas Christen

unread,
Feb 26, 2003, 4:45:19 PM2/26/03
to
Is there a way to read/obtain the other properties (e.g. file date) ?

> With the method you use, you need use java.util.zip package for further
processing
> to locate the entry you need.

I thougt that I have no access to the war file itself, so why using the zip
methodes ?

Thanks for clarification
Tomy


Xiang Rao

unread,
Feb 26, 2003, 6:27:05 PM2/26/03
to

I never use java.util.zip package to retrieve property files stored in a WAR file.
But if the content you retrieve is a zip file, you should be able to get your
property file as a ZipEntry which has a getTime() method to retrieve modification
time.
0 new messages