Hi there,
Here's what I found so far:
1.) I found that the more modern way of accessing scalar environment
attributes seems to be JNDI.
2.) JNDI environment entries can be stored in web.xml
3.)
web.xml file:
<env-entry>
<env-entry-name>testvaluewebxml</env-entry-name>
<env-entry-value>value1</env-entry-value>
<env-entry-type>java.lang.String</env-entry-type>
</env-entry>
4.)
Lookup using Java Code:
try {
Context globalctx = new InitialContext();
String envEntry = null;
envEntry = (String)
globalctx.lookup("java:comp/env/testvaluewebxml");
out.println("envEntry testvaluewebxml: " + envEntry);
} catch (Exception e) {
out.println("<li>Cannot get env-entry on JNDI " + e + "</li>");
return;
}
I didn't find such an example in the JNDI resources howto
(http://jakarta.apache.org/tomcat/tomcat-4.1-doc/jndi-resources-howto.html)
, but I think it would be cool to have such one.
p.s. Does anybody know how to access e.g. java:comp/env/ to read all
environment entries available? Maybe even a code sample to share??
thx alot
Johannes