You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris <ch...@yahoo.fr> on 2013/09/06 10:40:03 UTC

Struts 2.3.15.1 How to read external properties files or conf files

Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 


Is there any example with external files .
Not an upload  file by input forms. .

Or do we have to use another java classes ? 

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
Hi,
OK for refactoring database access out of the action.
But the problem is still there :  How to find a good framework to read external files in a struts web application ?




________________________________
 De : Miguel Almeida <mi...@almeida.at>
À : Chris <ch...@yahoo.fr> 
Cc : "umeshawasthi@gmail.com" <um...@gmail.com>; Struts Users Mailing List <us...@struts.apache.org> 
Envoyé le : Vendredi 6 septembre 2013 13h15
Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
 

Without any code it's hard to know what's happening.

I do ask you to seriously reconsider refactoring database access out of
the action or you'll end up with a huge, very hard to test action class.

Miguel Almeida

On Fri, 2013-09-06 at 10:50 +0100, Chris wrote:

> Where : server side , in action , like ActionSupport 
> 
> First  example : Login.java ( like in struts-2.3.15.1-blank ) 
> class Login extends com.opensymphony.xwork2.ActionSupport 
> to check and validate user/password ( I need access to LDAP or database ) 
> 
> Second Example: A User Request 
> After success login, a web user need to access data ( from LDAP or Database )  
> 
> 
> java.io.FileNotFoundException : jdbc.properties 
> or
> 
> java.io.FileNotFoundException : ldapconfiguration.conf
> 
> 
> Regards
> 
> 
> ________________________________
>  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>; Chris <ch...@yahoo.fr> 
> Envoyé le : Vendredi 6 septembre 2013 10h50
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
>  
> 
> Log4j file will be ready by Log4j framework and not exactly by struts2
> 
> Can you define where and how you want to read your property files? 
> Sent from BlackBerry® on Airtel
> 
> -----Original Message-----
> From: Chris <ch...@yahoo.fr>
> Date: Fri, 6 Sep 2013 09:40:03 
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Struts 2.3.15.1 How to read external properties files or conf files
> 
> Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
> But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 
> 
> 
> Is there any example with external files .
> Not an upload  file by input forms. .
> 
> Or do we have to use another java classes ?

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Miguel Almeida <mi...@almeida.at>.
Without any code it's hard to know what's happening.

I do ask you to seriously reconsider refactoring database access out of
the action or you'll end up with a huge, very hard to test action class.

Miguel Almeida

On Fri, 2013-09-06 at 10:50 +0100, Chris wrote:

> Where : server side , in action , like ActionSupport 
> 
> First  example : Login.java ( like in struts-2.3.15.1-blank ) 
> class Login extends com.opensymphony.xwork2.ActionSupport 
> to check and validate user/password ( I need access to LDAP or database ) 
> 
> Second Example: A User Request 
> After success login, a web user need to access data ( from LDAP or Database )  
> 
> 
> java.io.FileNotFoundException : jdbc.properties 
> or
> 
> java.io.FileNotFoundException : ldapconfiguration.conf
> 
> 
> Regards
> 
> 
> ________________________________
>  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>; Chris <ch...@yahoo.fr> 
> Envoyé le : Vendredi 6 septembre 2013 10h50
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
>  
> 
> Log4j file will be ready by Log4j framework and not exactly by struts2
> 
> Can you define where and how you want to read your property files? 
> Sent from BlackBerry® on Airtel
> 
> -----Original Message-----
> From: Chris <ch...@yahoo.fr>
> Date: Fri, 6 Sep 2013 09:40:03 
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Struts 2.3.15.1 How to read external properties files or conf files
> 
> Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
> But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 
> 
> 
> Is there any example with external files .
> Not an upload  file by input forms. .
> 
> Or do we have to use another java classes ?



Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Dave Newton <da...@gmail.com>.
I don't understand the problem.

Reading a file is trivial. Is the issue getting the values *out* of the
file? I mean, Java provides its own properties handling that can read
classpath resources.

Dave



On Fri, Sep 6, 2013 at 7:40 AM, Chris <ch...@yahoo.fr> wrote:

> In fact the problem is how to declare and use external files to work with
> external properties.
>
> host=xxx.xxx.xxx.xxx
> port=xxxx
> ...etc
>
> Should I understand that only few people use  external configuration files
> with struts web applications ?
>
>
>
> ________________________________
>  De : Dave Newton <da...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>
> Envoyé le : Vendredi 6 septembre 2013 13h17
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> How are you trying to load them? As a resource on the classpath?
>
> Dave
> On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:
>
> > Where : server side , in action , like ActionSupport
> >
> > First  example : Login.java ( like in struts-2.3.15.1-blank )
> > class Login extends com.opensymphony.xwork2.ActionSupport
> > to check and validate user/password ( I need access to LDAP or database )
> >
> > Second Example: A User Request
> > After success login, a web user need to access data ( from LDAP or
> > Database )
> >
> >
> > java.io.FileNotFoundException : jdbc.properties
> > or
> >
> > java.io.FileNotFoundException : ldapconfiguration.conf
> >
> >
> > Regards
> >
> >
> > ________________________________
> >  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> > À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> > christalkto@yahoo.fr>
> > Envoyé le : Vendredi 6 septembre 2013 10h50
> > Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> >
> > Log4j file will be ready by Log4j framework and not exactly by struts2
> >
> > Can you define where and how you want to read your property files?
> > Sent from BlackBerry® on Airtel
> >
> > -----Original Message-----
> > From: Chris <ch...@yahoo.fr>
> > Date: Fri, 6 Sep 2013 09:40:03
> > To: Struts Users Mailing List<us...@struts.apache.org>
> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Subject: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> > Using log4j.properties instead of log4j.xml is not a problem with Struts
> > 2.3.15.1 ( or should it be ? )
> > But with my own properties files ( jdbc.properties ) or configuration
> > files ( ldap.conf ) it doesn't work.
> >
> >
> > Is there any example with external files .
> > Not an upload  file by input forms. .
> >
> > Or do we have to use another java classes ?
>



-- 
e: davelnewton@gmail.com
m: 908-380-8699
s: davelnewton_skype
t: @dave_newton <https://twitter.com/dave_newton>
b: Bucky Bits <http://buckybits.blogspot.com/>
g: davelnewton <https://github.com/davelnewton>
so: Dave Newton <http://stackoverflow.com/users/438992/dave-newton>

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
Thanks Leonidas



________________________________
Hi there,


webwork used to have a class that would easily read
external sources like xml files, but i do not recall the class name now. If you want to read from simple property files you could use something 
like :

String path = ServletActionContext.getServletContext().getRealPath("");

Properties prop = new Properties();

try {
    // load properties from the class path
    prop.load(new FileInputStream(path
            + "//WEB-INF//classes//ldapconf.properties"));
} catch (IOException ex) {
    ex.printStackTrace();
}


//get parameter param1
String param1 = prop.getProperty("param1"); 

Regards

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Leonidas Papadakis <lp...@bluecore.gr>.
Hi there,

webwork used to have a class that would easily read external sources like
xml files, but i do not recall the class name now. If you want to read from
simple property files you could use something like :

String path = ServletActionContext.getServletContext().getRealPath("");

Properties prop = new Properties();

try {
    // load properties from the class path
    prop.load(new FileInputStream(path
            + "//WEB-INF//classes//ldapconf.properties"));
} catch (IOException ex) {
    ex.printStackTrace();
}

//get parameter param1
String param1 = prop.getProperty("param1");

Regards




On Fri, Sep 6, 2013 at 4:53 PM, Chris <ch...@yahoo.fr> wrote:

> Thanks  ,
> I 'll try with commons-configuration
>
>
> ________________________________
>  De : Umesh Awasthi <um...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> christalkto@yahoo.fr>
> Envoyé le : Vendredi 6 septembre 2013 13h45
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> Have you tried http://commons.apache.org/proper/commons-configuration/
> it can read various type of property files
>
>
> On Fri, Sep 6, 2013 at 5:10 PM, Chris <ch...@yahoo.fr> wrote:
>
> > In fact the problem is how to declare and use external files to work with
> > external properties.
> >
> > host=xxx.xxx.xxx.xxx
> > port=xxxx
> > ...etc
> >
> > Should I understand that only few people use  external configuration
> files
> > with struts web applications ?
> >
> >
> >
> > ________________________________
> >  De : Dave Newton <da...@gmail.com>
> > À : Struts Users Mailing List <us...@struts.apache.org>
> > Envoyé le : Vendredi 6 septembre 2013 13h17
> > Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> >
> > How are you trying to load them? As a resource on the classpath?
> >
> > Dave
> > On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:
> >
> > > Where : server side , in action , like ActionSupport
> > >
> > > First  example : Login.java ( like in struts-2.3.15.1-blank )
> > > class Login extends com.opensymphony.xwork2.ActionSupport
> > > to check and validate user/password ( I need access to LDAP or
> database )
> > >
> > > Second Example: A User Request
> > > After success login, a web user need to access data ( from LDAP or
> > > Database )
> > >
> > >
> > > java.io.FileNotFoundException : jdbc.properties
> > > or
> > >
> > > java.io.FileNotFoundException : ldapconfiguration.conf
> > >
> > >
> > > Regards
> > >
> > >
> > > ________________________________
> > >  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> > > À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> > > christalkto@yahoo.fr>
> > > Envoyé le : Vendredi 6 septembre 2013 10h50
> > > Objet : Re: Struts 2.3.15.1 How to read external properties files or
> conf
> > > files
> > >
> > >
> > > Log4j file will be ready by Log4j framework and not exactly by struts2
> > >
> > > Can you define where and how you want to read your property files?
> > > Sent from BlackBerry® on Airtel
> > >
> > > -----Original Message-----
> > > From: Chris <ch...@yahoo.fr>
> > > Date: Fri, 6 Sep 2013 09:40:03
> > > To: Struts Users Mailing List<us...@struts.apache.org>
> > > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > > Subject: Struts 2.3.15.1 How to read external properties files or conf
> > > files
> > >
> > > Using log4j.properties instead of log4j.xml is not a problem with
> Struts
> > > 2.3.15.1 ( or should it be ? )
> > > But with my own properties files ( jdbc.properties ) or configuration
> > > files ( ldap.conf ) it doesn't work.
> > >
> > >
> > > Is there any example with external files .
> > > Not an upload  file by input forms. .
> > >
> > > Or do we have to use another java classes ?
> >
>
>
>
> --
> With Regards
> Umesh Awasthi
> http://www.travellingrants.com/

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
Thanks  ,
I 'll try with commons-configuration


________________________________
 De : Umesh Awasthi <um...@gmail.com>
À : Struts Users Mailing List <us...@struts.apache.org>; Chris <ch...@yahoo.fr> 
Envoyé le : Vendredi 6 septembre 2013 13h45
Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
 

Have you tried http://commons.apache.org/proper/commons-configuration/
it can read various type of property files


On Fri, Sep 6, 2013 at 5:10 PM, Chris <ch...@yahoo.fr> wrote:

> In fact the problem is how to declare and use external files to work with
> external properties.
>
> host=xxx.xxx.xxx.xxx
> port=xxxx
> ...etc
>
> Should I understand that only few people use  external configuration files
> with struts web applications ?
>
>
>
> ________________________________
>  De : Dave Newton <da...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>
> Envoyé le : Vendredi 6 septembre 2013 13h17
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> How are you trying to load them? As a resource on the classpath?
>
> Dave
> On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:
>
> > Where : server side , in action , like ActionSupport
> >
> > First  example : Login.java ( like in struts-2.3.15.1-blank )
> > class Login extends com.opensymphony.xwork2.ActionSupport
> > to check and validate user/password ( I need access to LDAP or database )
> >
> > Second Example: A User Request
> > After success login, a web user need to access data ( from LDAP or
> > Database )
> >
> >
> > java.io.FileNotFoundException : jdbc.properties
> > or
> >
> > java.io.FileNotFoundException : ldapconfiguration.conf
> >
> >
> > Regards
> >
> >
> > ________________________________
> >  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> > À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> > christalkto@yahoo.fr>
> > Envoyé le : Vendredi 6 septembre 2013 10h50
> > Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> >
> > Log4j file will be ready by Log4j framework and not exactly by struts2
> >
> > Can you define where and how you want to read your property files?
> > Sent from BlackBerry® on Airtel
> >
> > -----Original Message-----
> > From: Chris <ch...@yahoo.fr>
> > Date: Fri, 6 Sep 2013 09:40:03
> > To: Struts Users Mailing List<us...@struts.apache.org>
> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Subject: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> > Using log4j.properties instead of log4j.xml is not a problem with Struts
> > 2.3.15.1 ( or should it be ? )
> > But with my own properties files ( jdbc.properties ) or configuration
> > files ( ldap.conf ) it doesn't work.
> >
> >
> > Is there any example with external files .
> > Not an upload  file by input forms. .
> >
> > Or do we have to use another java classes ?
>



-- 
With Regards
Umesh Awasthi
http://www.travellingrants.com/

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Umesh Awasthi <um...@gmail.com>.
Have you tried http://commons.apache.org/proper/commons-configuration/
it can read various type of property files


On Fri, Sep 6, 2013 at 5:10 PM, Chris <ch...@yahoo.fr> wrote:

> In fact the problem is how to declare and use external files to work with
> external properties.
>
> host=xxx.xxx.xxx.xxx
> port=xxxx
> ...etc
>
> Should I understand that only few people use  external configuration files
> with struts web applications ?
>
>
>
> ________________________________
>  De : Dave Newton <da...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>
> Envoyé le : Vendredi 6 septembre 2013 13h17
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> How are you trying to load them? As a resource on the classpath?
>
> Dave
> On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:
>
> > Where : server side , in action , like ActionSupport
> >
> > First  example : Login.java ( like in struts-2.3.15.1-blank )
> > class Login extends com.opensymphony.xwork2.ActionSupport
> > to check and validate user/password ( I need access to LDAP or database )
> >
> > Second Example: A User Request
> > After success login, a web user need to access data ( from LDAP or
> > Database )
> >
> >
> > java.io.FileNotFoundException : jdbc.properties
> > or
> >
> > java.io.FileNotFoundException : ldapconfiguration.conf
> >
> >
> > Regards
> >
> >
> > ________________________________
> >  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> > À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> > christalkto@yahoo.fr>
> > Envoyé le : Vendredi 6 septembre 2013 10h50
> > Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> >
> > Log4j file will be ready by Log4j framework and not exactly by struts2
> >
> > Can you define where and how you want to read your property files?
> > Sent from BlackBerry® on Airtel
> >
> > -----Original Message-----
> > From: Chris <ch...@yahoo.fr>
> > Date: Fri, 6 Sep 2013 09:40:03
> > To: Struts Users Mailing List<us...@struts.apache.org>
> > Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> > Subject: Struts 2.3.15.1 How to read external properties files or conf
> > files
> >
> > Using log4j.properties instead of log4j.xml is not a problem with Struts
> > 2.3.15.1 ( or should it be ? )
> > But with my own properties files ( jdbc.properties ) or configuration
> > files ( ldap.conf ) it doesn't work.
> >
> >
> > Is there any example with external files .
> > Not an upload  file by input forms. .
> >
> > Or do we have to use another java classes ?
>



-- 
With Regards
Umesh Awasthi
http://www.travellingrants.com/

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
In fact the problem is how to declare and use external files to work with external properties.

host=xxx.xxx.xxx.xxx
port=xxxx
...etc

Should I understand that only few people use  external configuration files with struts web applications ?



________________________________
 De : Dave Newton <da...@gmail.com>
À : Struts Users Mailing List <us...@struts.apache.org> 
Envoyé le : Vendredi 6 septembre 2013 13h17
Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
 

How are you trying to load them? As a resource on the classpath?

Dave
On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:

> Where : server side , in action , like ActionSupport
>
> First  example : Login.java ( like in struts-2.3.15.1-blank )
> class Login extends com.opensymphony.xwork2.ActionSupport
> to check and validate user/password ( I need access to LDAP or database )
>
> Second Example: A User Request
> After success login, a web user need to access data ( from LDAP or
> Database )
>
>
> java.io.FileNotFoundException : jdbc.properties
> or
>
> java.io.FileNotFoundException : ldapconfiguration.conf
>
>
> Regards
>
>
> ________________________________
>  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> christalkto@yahoo.fr>
> Envoyé le : Vendredi 6 septembre 2013 10h50
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> Log4j file will be ready by Log4j framework and not exactly by struts2
>
> Can you define where and how you want to read your property files?
> Sent from BlackBerry® on Airtel
>
> -----Original Message-----
> From: Chris <ch...@yahoo.fr>
> Date: Fri, 6 Sep 2013 09:40:03
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Struts 2.3.15.1 How to read external properties files or conf
> files
>
> Using log4j.properties instead of log4j.xml is not a problem with Struts
> 2.3.15.1 ( or should it be ? )
> But with my own properties files ( jdbc.properties ) or configuration
> files ( ldap.conf ) it doesn't work.
>
>
> Is there any example with external files .
> Not an upload  file by input forms. .
>
> Or do we have to use another java classes ?

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Dave Newton <da...@gmail.com>.
How are you trying to load them? As a resource on the classpath?

Dave
On Sep 6, 2013 5:51 AM, "Chris" <ch...@yahoo.fr> wrote:

> Where : server side , in action , like ActionSupport
>
> First  example : Login.java ( like in struts-2.3.15.1-blank )
> class Login extends com.opensymphony.xwork2.ActionSupport
> to check and validate user/password ( I need access to LDAP or database )
>
> Second Example: A User Request
> After success login, a web user need to access data ( from LDAP or
> Database )
>
>
> java.io.FileNotFoundException : jdbc.properties
> or
>
> java.io.FileNotFoundException : ldapconfiguration.conf
>
>
> Regards
>
>
> ________________________________
>  De : "umeshawasthi@gmail.com" <um...@gmail.com>
> À : Struts Users Mailing List <us...@struts.apache.org>; Chris <
> christalkto@yahoo.fr>
> Envoyé le : Vendredi 6 septembre 2013 10h50
> Objet : Re: Struts 2.3.15.1 How to read external properties files or conf
> files
>
>
> Log4j file will be ready by Log4j framework and not exactly by struts2
>
> Can you define where and how you want to read your property files?
> Sent from BlackBerry® on Airtel
>
> -----Original Message-----
> From: Chris <ch...@yahoo.fr>
> Date: Fri, 6 Sep 2013 09:40:03
> To: Struts Users Mailing List<us...@struts.apache.org>
> Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
> Subject: Struts 2.3.15.1 How to read external properties files or conf
> files
>
> Using log4j.properties instead of log4j.xml is not a problem with Struts
> 2.3.15.1 ( or should it be ? )
> But with my own properties files ( jdbc.properties ) or configuration
> files ( ldap.conf ) it doesn't work.
>
>
> Is there any example with external files .
> Not an upload  file by input forms. .
>
> Or do we have to use another java classes ?

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
Where : server side , in action , like ActionSupport 

First  example : Login.java ( like in struts-2.3.15.1-blank ) 
class Login extends com.opensymphony.xwork2.ActionSupport 
to check and validate user/password ( I need access to LDAP or database ) 

Second Example: A User Request 
After success login, a web user need to access data ( from LDAP or Database )  


java.io.FileNotFoundException : jdbc.properties 
or

java.io.FileNotFoundException : ldapconfiguration.conf


Regards


________________________________
 De : "umeshawasthi@gmail.com" <um...@gmail.com>
À : Struts Users Mailing List <us...@struts.apache.org>; Chris <ch...@yahoo.fr> 
Envoyé le : Vendredi 6 septembre 2013 10h50
Objet : Re: Struts 2.3.15.1 How to read external properties files or conf files
 

Log4j file will be ready by Log4j framework and not exactly by struts2

Can you define where and how you want to read your property files? 
Sent from BlackBerry® on Airtel

-----Original Message-----
From: Chris <ch...@yahoo.fr>
Date: Fri, 6 Sep 2013 09:40:03 
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Struts 2.3.15.1 How to read external properties files or conf files

Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 


Is there any example with external files .
Not an upload  file by input forms. .

Or do we have to use another java classes ?

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by um...@gmail.com.
Log4j file will be ready by Log4j framework and not exactly by struts2

Can you define where and how you want to read your property files? 
Sent from BlackBerry® on Airtel

-----Original Message-----
From: Chris <ch...@yahoo.fr>
Date: Fri, 6 Sep 2013 09:40:03 
To: Struts Users Mailing List<us...@struts.apache.org>
Reply-To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: Struts 2.3.15.1 How to read external properties files or conf files

Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 


Is there any example with external files .
Not an upload  file by input forms. .

Or do we have to use another java classes ?

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

Re: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Chris <ch...@yahoo.fr>.
Well, I have absolutely no problem with log4j.properties as I said above.
I'm just trying to find a framework for all other external files
 ( .properties or .configuration or unname.properties files ) 




________________________________
 De : Martin Gainty <mg...@hotmail.com>
À : Struts Users Mailing List <us...@struts.apache.org> 
Envoyé le : Vendredi 6 septembre 2013 13h13
Objet : RE: Struts 2.3.15.1 How to read external properties files or conf files
 

if you did not place log4j.properties on classpath then

<SystemProperty>
Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value "log4j.properties".

http://logging.apache.org/log4j/1.2/manual.html
</SystemProperty>



<Code>

then use Log4j Loader.getResource to load properties file

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/Loader.html#getResourcejava.lang.String

</Code>


Bon Chance,
Martin 
______________________________________________ 
Note de déni et de confidentialité

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

  


> Date: Fri, 6 Sep 2013 09:40:03 +0100
> From: christalkto@yahoo.fr
> Subject: Struts 2.3.15.1 How to read external properties files or conf files
> To: user@struts.apache.org
> 
> Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
> But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 
> 
> 
> Is there any example with external files .
> Not an upload  file by input forms. .
> 
> Or do we have to use another java classes ? 

RE: Struts 2.3.15.1 How to read external properties files or conf files

Posted by Martin Gainty <mg...@hotmail.com>.
if you did not place log4j.properties on classpath then

<SystemProperty>
Set the resource string variable to the value of the log4j.configuration system property. The preferred way to specify the default initialization file is through the log4j.configuration system property. In case the system property log4j.configuration is not defined, then set the string variable resource to its default value "log4j.properties".

http://logging.apache.org/log4j/1.2/manual.html
</SystemProperty>

 

<Code>

then use Log4j Loader.getResource to load properties file

http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/helpers/Loader.html#getResourcejava.lang.String

</Code>


Bon Chance,
Martin 
______________________________________________ 
Note de déni et de confidentialité

Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.

  


> Date: Fri, 6 Sep 2013 09:40:03 +0100
> From: christalkto@yahoo.fr
> Subject: Struts 2.3.15.1 How to read external properties files or conf files
> To: user@struts.apache.org
> 
> Using log4j.properties instead of log4j.xml is not a problem with Struts 2.3.15.1 ( or should it be ? ) 
> But with my own properties files ( jdbc.properties ) or configuration files ( ldap.conf ) it doesn't work. 
> 
> 
> Is there any example with external files .
> Not an upload  file by input forms. .
> 
> Or do we have to use another java classes ?