struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <>
Subject Re: OutputStreamPath
Date Thu, 01 Mar 2007 20:52:22 GMT
Dave Newton wrote:
> --- Daniel Chacón Sánchez <>
>> I have a question, how I can set the path for the
>> OutputStream like i get it for the InputStream with 
>> getResourceAsStream?
> I'm not sure you can do that, particularly since a
> resource might be inside a JAR file or be located in a
> place you do not have write acess to.

Yup, there's no guarantee that the contents of a webapp can be written 
to in all deployment contexts. However, as long as you know you will be 
deploying it to a container that allows the file to be written to, you 
should be OK.

> If you know that the properties file is in a specific
> place and that it makes sense to write to it then I
> would think you'd use typical file i/o and determine
> the path via getRealPath.

In your case, a simple change to the code you've already written should 
do the trick. Something like this (untested):

     URL res = Thread.currentThread()

     InputStream input = new FileInputStream(res);

     //Load the properties


     // Save the properties
     OutputStream out = new FileOutputStream(res);, "");

> It confuses me why you'd want to do this in a webapp,
> though. Settings you are likely to modify from within
> the app should be in a database, not a properties file
> (IMO, anyway).

Agreed. Or otherwise externalized, for example through JNDI or something.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message