You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Frank <su...@gmail.com> on 2006/01/25 00:23:59 UTC
Configure my application
Hi,
How do I get parameters from a XML file ? Ex. for configure my JDBC driver.
Regards
Re: Configure my application
Posted by Lindsay Steele <ls...@iinet.net.au>.
Frank wrote:
> Hi,
>
> How do I get parameters from a XML file ? Ex. for configure my JDBC driver.
>
> Regards
>
>
Using something like Cayenne for easy to use data access ...
(http://www.objectstyle.org/cayenne/)
or
You could use environmental entries in the web.xml:
<env-entry>
<env-entry-name>adminUsername</env-entry-name>
<env-entry-value>admin</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
<env-entry>
<env-entry-name>adminPassword</env-entry-name>
<env-entry-value>xxxxxxxxx</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
Then get them in your code by using .....
String adminUsername = "";
String adminPassword = "";
javax.naming.Context ctx = null;
try {
ctx = new javax.naming.InitialContext();
if (ctx == null) {
System.out.println("Context is null in web.xml");
}
} catch (Exception e) {
System.out.println(e);
}
try {
adminUsername = (String)
ctx.lookup("java:comp/env/adminUsername");
adminPassword = (String)
ctx.lookup("java:comp/env/adminPassword");
} catch (Exception e) {
System.out.println(e);
}
or you could research how to read values from an xml file, something
which is not really related to Tapestry.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org