vikas rao schrieb:
No, Martin, I wasnt looking at plain xml reading ,in that case i could
just
use a normal parser and get the values right?
Thanks,
Vikas.
Yes, sure, you could just use an XML parser and do your own stuff. The
problem with this approach would be that changing your XML structure
would probably mean changing a lot of the processing.
This type of processing is handled by Digester which was originally made
to deal with Struts config files. It will (called at an appropriate time
in your app's lifecycle) convert your configuration information into
(one or several) Java beans which your application can access. Seems for
me exactly the thing you are looking for.
The other question is whether this machinery is worthwhile, if you are
just having a few key-value pairs which probably would be easier be put
into some plain text file (e. g a .properties file).
To give you an example how I do configuration in my Struts (1.x) based apps:
I introduce a plugin where I pass the path of the config-file as a
parameter in struts-config.xml.
In the init-method of the plugin I use digester to transfer the
information from my config file into a configuration bean which is put
into application scope. From there it can be accessed when needed.
Martin
On 5/21/07, vikas rao <[EMAIL PROTECTED]> wrote:
Hi,
Can someone point out a tutorial or some place where I can learn how to
read values from a .cfg file?
Say I have a Input.cfg file which goes like:
<com>
<MyCompany>
<Common
inputDir="C:/vray/xml_files/"
outputDir="C:/xm_output"
/>
</MyCompany>
</com>
Now, if I need the inputDir value inside my program, how do I do it?
Sorry that this is off topic from struts, but i cant seem to find some
sensible help.
Any help will be appreciated.
Thanks.
Vikas.
--
----------------------------------------------
Martin Kindler
Kaulbachstr. 20a
D-12247 Berlin
Deutschland
E-Mail: [EMAIL PROTECTED]
Tel. +49 (030) 260 78 48 1
Fax +49 (030) 260 78 48 3
GSM +49 (0160) 977 636 14
Skype martin.kindler
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]