You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Mouratidis, Georg" <GM...@heiler.com> on 2003/05/13 16:11:29 UTC

Access to property file from a normal class

Hi at all,

how can i access to a key-value pair from a struts-propertie file.

For example:

i have ApplicationRessources.propertie under /WEB-INF/classes/resources.
And i want to have access to this propertie file from a normal class. not a Action class. 
But when i try to implement it regarding to the documentation i always receive null.

Can somebody help me?


<here is the code>

import org.apache.struts.util.MessageResources;
import org.apache.struts.util.PropertyMessageResourcesFactory;
public class Database
{
public Database()
{
}
// Should be done just once, so placed it in static class initialization section
static
{
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch (ClassNotFoundException e)
{
e.printStackTrace();
System.out.println("ClassNotFoundException : " + e.getMessage());
}
}
public IUDAConnection connectToDatabase(String dbConnectString)
{
IUDAConnection conn;
conn = null;
PropertyMessageResourcesFactory propFactory = new PropertyMessageResourcesFactory();
MessageResources messagesSetup = propFactory.createResources("PSX_SETUP_RESOURCE_KEY");
String udaConfigPath = messagesSetup.getMessage("uda.config.path");   <------------ udaConfigPath should not be NULL --------------------------------
System.out.println("[UDA CONFIG PATH] : " + udaConfigPath);
UDA uda = UDA.createInstance("C:/work/PSX_1_1/conf/uda-config.xml");
conn = uda.getConnection("PSX");
return conn;
}
}


mit freundlichen Grüßen 

Georg XL. Mouratidis 
Projektleiter 

Heiler|Software AG
Mittlerer Pfad 9 
D-70499 Stuttgart 

Tel: 0711-139 84-265
Fax: 0711-866 63 01 
Email: gmouratidis@heiler.com 

Connecting Buyer and Supplier
http://www.heiler.com 




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