[prev in list] [next in list] [prev in thread] [next in thread] 

List:       struts-user
Subject:    Re: Handling config files
From:       gramani () intellicare ! com
Date:       2005-12-08 22:08:59
Message-ID: OF74E13085.5C297FA3-ON852570D1.00787EDD-852570D1.0079A9F9 () intellicare ! com
[Download RAW message or body]

--=_alternative 0079A9F8852570D1_=
Content-Type: text/plain; charset="US-ASCII"

Hi Sebastain,

There are probably many ways of doing this (I don't know of any "standard" 
way though). Here's some code which i use to populate a Properties object 
from a file:

String xpdlPropertiesFileName = "xpdl.properties"; //file should be in the 
class path..
InputStream is = null;
ClassLoader loader = Thread.currentThread().getContextClassLoader();
is = loader.getResourceAsStream(xpdlPropertiesFileName);

//read the properties..
if (!initialized ) {
        if (is != null) {
                processVariables = new Properties();
                processVariables.load(is);
                initialized = true;
        }
        else log.error("Aaaarrgghhh!! xpdl.properties file dne!!!");
}

Regards,
Geeta

Sebastian Stein <seb.stein@hpfsc.de> wrote on 12/08/2005 04:45:15 PM:

> Hi,
> 
> I have a config file in WEB-INF/classes/ directory. This file has the
> information for database connection. How can I make this file accessible 
in
> all Action classes? I guess there must be a unified way to access such a
> file.
> 
> 
> Sebastian
> 
--=_alternative 0079A9F8852570D1_=--
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic