I'm having problems reading global environment variables from a servlet
running in a tomcat container.
I'm creating a datasource and several environment variables through the
tomcat admin screens and then trying to access them from my web
application with no success.
Any information or suggestions as to where I am going wrong would be
appreciated.
David Chamberlin
UNDP Ecuador
Here's the tomcat admin screen for a typical environment variable.
Name: opensite.repository
Type: java.lang.String
Value: d:\David\repository
Override Application Level Entries: Yes
Description: Path to opensite repository
Here's the corresponding entry in web.xml
<resource-env-ref>
<resource-env-ref-name>opensite.repository</resource-env-ref-name>
<resource-env-ref-type>java.lang.String</resource-env-ref-type>
</resource-env-ref>
And here is the java code to access the variable.
try {
Context ctx = new InitialContext();
m_envCtx = (Context)ctx.lookup("java:comp/env");
} catch (Exception e) {
if (m_inContainer)
m_log.log(Level.WARNING, "Can't get container
context", e);
}
try {
m_repository = (String)
m_envCtx.lookup("opensite.repository");
} catch (Exception e) {
m_repository = m_tempDir + File.separator +
"opensiterepository";
}
The entry in server.xml written by the admin program is as follows:
<Environment description="Path to opensite repository"
name="opensite.repository" override="true" type="java.lang.String"
value="d:\David\repository"/>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]