tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Chamberlin" <>
Subject problems reading global environment variables.
Date Wed, 23 Jul 2003 15:54:32 GMT
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

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

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)
                } catch (Exception e) {
                    m_repository = m_tempDir + File.separator +

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"

View raw message