struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Venkata Phani Kumar" <venkat...@ocimumbio.com>
Subject Re: Updating a config(.ini) file in Action class
Date Wed, 06 Dec 2006 07:14:00 GMT
Hi,
You can get any resource path wich is under context path using
ServeletContext.getRealPath().
The usage of this method is here,
                String iniFilePath =
request.getSession().getServletContext().getRealPath("test.ini");

you can use the 'iniFilePath' to instatiate FileOutStream, and do what ever
you want.

Hope this will help you out....

Regards,
Venkata Phanikumar. G
----- Original Message ----- 
From: "chuanjiang lo" <lochuanjiang@gmail.com>
To: <user@struts.apache.org>
Sent: Wednesday, December 06, 2006 12:21 PM
Subject: Updating a config(.ini) file in Action class


> Hi all,
>
> I have this web app that allows user to change the config (.ini) file via
a
> form. When the user submits the form, it goes into the action class and
the
> action class is supposed to update the ini file accordingly.
>
> The ini file is lumped together with my action class.
>
> FileInputStream in = new FileInputStream("test.ini");
> Properties p = new Properties();
> p.load(in);
> p.setProperty("User name", username);
> p.setProperty("Password", password);
> p.store(new FileOutputStream("test.ini"), null);
>
> However the ini file is not updated in the webapp directory.
> if i change p.store(new FileOutputStream("test.ini"), null); to
p.store(new
> FileOutputStream("c:\\test.ini"), null);
> The test.ini will appear in c:\
>
> How should i go abt updating the ini file that is together with the
webapp?
>
> Appreciate any advice
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message