You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Josh G <jo...@gfunk007.com> on 2004/07/01 04:08:22 UTC

Re: values in server.xml -Answered, for the archives

In server.xml, under <DefaultContext>:

    <Environment name="foo" type="java.lang.String" value="bar"/>

And in web.xml:

    <env-entry>
      <env-entry-name>foo</env-entry-name>
      <env-entry-type>java.lang.String</env-entry-type>
    </env-entry>

And the code to get it back (include javax.naming.*):

    Context initCtx = new InitialContext();
    Context envCtx = (Context) initCtx.lookup("java:comp/env");
    String jndiFoo = (String)envCtx.lookup("foo");

Cheers,
-Josh

--

Max Power, he's the man who's name you'd love to touch! But you mustn't 
touch!
His name sounds good in your ear, but when you say it, you mustn't fear!
'Cause his name can be said by anyone!

      [ Josh 'G-Funk' McDonald ]  --  [ Pirion Systems, Brisbane]

[ 07 3257 0490 ]  --  [ 0415 784 825 ]  --  [ http://www.gfunk007.com/ ]

----- Original Message ----- 
From: "Josh G" <jo...@gfunk007.com>
To: "Tomcat Users List" <to...@jakarta.apache.org>
Sent: Wednesday, June 30, 2004 4:22 PM
Subject: <environment> values in server.xml


Where should I put <environment> values in server.xml? And more importantly, 
how on earth do I retrieve them programmatically? The documentation on this 
sort of stuff is either unbelievably inadequate or incredibly hard to find.

Or c) I'm a dickhead. Either way, I could really use a hand. I'm just trying 
to get a string out of server.xml - not web.xml.

Cheers,
-Josh

--

Max Power, he's the man who's name you'd love to touch! But you mustn't 
touch!
His name sounds good in your ear, but when you say it, you mustn't fear!
'Cause his name can be said by anyone!

      [ Josh 'G-Funk' McDonald ]  --  [ Pirion Systems, Brisbane]

[ 07 3257 0490 ]  --  [ 0415 784 825 ]  --  [ http://www.gfunk007.com/ ]


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