Hi all,
I have this servlet that when it is called, it would update a
config(.ini) file that is bundled with it together as a webapp.
Users are able to enter a new username via a form and the servlet will
be called when the user press the submit button.
However the test.ini is not updated, any ideas to solve this issues?
FileInputStream in = new FileInputStream("test.ini");
Properties p = new Properties();
p.load(in);
p.setProperty("MailUserName", +userName);
p.store(new FileOutputStream("test.ini"), null);
There isn't any issues if an absolute path is given but i would need to
update the test.ini that is within the webapp.
p.store(new FileOutputStream("c:\\test.ini"), null);
Appreciate any advice
Simon Brooke - 06 Dec 2006 17:00 GMT
> Hi all,
>
[quoted text clipped - 5 lines]
>
> However the test.ini is not updated, any ideas to solve this issues?
You cannot write into a webapp which does not get unpacked. If you are
using Tomcat, check that unpackWARs="true" in the server.xml file.
You can get a directory you can write to within your webapp using the
following:
uploadDirPath =
config.getServletContext( ).getInitParameter( "upload_dir_path" );
File uploadDir =
new File( getServletContext( ).getRealPath( uploadDirPath ) );
if ( !uploadDir.isDirectory( ) || !uploadDir.canWrite( ) )
{
throw new UnavailableException(
"Cannot write to upload directory " +
uploadDirPath );
}

Signature
simon@jasmine.org.uk (Simon Brooke) http://www.jasmine.org.uk/~simon/
'graveyards are full of indispensable people'