Hello Juri,
Well, don't use File io in a servlet application unless you are
reading/writing to a place guaranteed to be read/writable such as each
context's temp dir made available by any server implementing the
Servlet 2.3 spec.
To read a config file in a servlet portable way, do the following:
InputStream is =
getServletContext().getResourceAsStream("/WEB-INF/testApp.properties");
That will read the testApp.properties file in the current context's
WEB-INF directory whether the context is being served out of a
directory on the filesystem or out of a .war archive.
You can also try this, if your testApp.properties is in the path of
one of the available classloaders:
InputStream stream =
Thread.currentThread().getContextClassLoader().getResourceAsStream("myApp.pr
operties");
Or use the following if your properties file is in the same relative
location as the class that is loading it.
InputStream propsStream = this.getClass().getResourceAsStream("testApp.properties");
or like this if you put the testApp.properties in the root of the
current classloader (meaning "WEB-INF/classes"):
InputStream propsStream =
this.getClass().getResourceAsStream("/testApp.properties");
There you go. Lots of possibilities.
Jake
Monday, August 19, 2002, 6:41:07 AM, you wrote:
JF> solved it by myself...
JF> The problem was, that the servlett was trying to read a properties file
JF> included in the war file.
JF> Any suggestions for a workaround? I.e. using webresources or the like...
JF> Best regards
JF> Juri
JF> --
JF> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
JF> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
--
Best regards,
Jacob mailto:[EMAIL PROTECTED]
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>