Doing it the way you describe will only work from a servlet. If that is
ok, stop reading and do it that way. :-)
A more general way would be to use a classloader instead. There are many
good articles on how to do this (google for 'classloader resource'), but
one simple way is this:
InputStream is =
getClass().getClassLoader().
getResourceAsStream("foo.xml");
To do this, the resource foo.xml *must* be on your classpath. If it is
in a package, you need to specify that in the call made to the
getResourceAsStream() method. Also this cannot be done in a static
context. If you are in a static block of code, you can use this instead:
InputStream is =
Thread.currentThread().getContextClassLoader().
getResourceAsStream("foo.xml");
Larry
>>> [EMAIL PROTECTED] 10/19/03 10:22 AM >>>
Hallo,
I thinkin how I can read the xml file from /WEB-INF directory.
I found something as
InputStream is =
servletContext.getResourceAsStream("/WEB-INF/something.xml")
but how I can get servletContext?. Or, is t good way to read data, as
datasource names, from xml file and store it as instance of config file
in
session? is there any better way?
Thanks for help,
Jiri
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]