You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by me...@bpam.fr on 2002/09/16 09:10:12 UTC

Réf. : Accessing environmental variables

You must first create an initial context object like this
 Context ctx = new InitialContext();

  and acces your value like this
String value =(String)ctx.lookup("java:/comp/env/owner");

Meissa




"neal" <ne...@yahoo.com> on 16/09/2002 06:42:03

Veuillez répondre à "Tomcat Users List" <to...@jakarta.apache.org>

Pour :    "Tomcat Users List" <to...@jakarta.apache.org>
cc :
Objet :   Accessing environmental variables


How does one access these environmental variables being assigned from the
web.xml file?

I have tried accessing the servletContext presuming it would be available
there but no luck - its coming back null.  :(

    ServletContext application = getServletContext();
    String owner = (String)application.getAttribute("owner");

And here's my variable definition from the web.xml file:

   <!-- Environmental Variables Definitions -->
   <env-entry>
     <env-entry-name>owner</env-entry-name>
     <env-entry-value>Neal</env-entry-value>
     <env-entry-type>java.lang.String</env-entry-type>
   </env-entry>
   <!-- /Environmental Variables Definitions -->


Thanks.
Neal



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>








--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Réf. : Accessing environmental variables

Posted by neal <ne...@yahoo.com>.
Ooooh!

I saw a similar example for connection pooling in Tomcat (using the intial
context to retrieve settings).  I didn't realize that was also how to gain
access to the environmental variables.  And I guess that's why I couldn't
find the docs ... I didn't realize it was a JNDI topic.

:)

THanks!

Neal


-----Original Message-----
From: meissa.Sakho@bpam.fr [mailto:meissa.Sakho@bpam.fr]
Sent: Monday, September 16, 2002 12:10 AM
To: Tomcat Users List
Subject: Réf. : Accessing environmental variables


You must first create an initial context object like this
 Context ctx = new InitialContext();

  and acces your value like this
String value =(String)ctx.lookup("java:/comp/env/owner");

Meissa




"neal" <ne...@yahoo.com> on 16/09/2002 06:42:03

Veuillez répondre à "Tomcat Users List" <to...@jakarta.apache.org>

Pour :    "Tomcat Users List" <to...@jakarta.apache.org>
cc :
Objet :   Accessing environmental variables


How does one access these environmental variables being assigned from the
web.xml file?

I have tried accessing the servletContext presuming it would be available
there but no luck - its coming back null.  :(

    ServletContext application = getServletContext();
    String owner = (String)application.getAttribute("owner");

And here's my variable definition from the web.xml file:

   <!-- Environmental Variables Definitions -->
   <env-entry>
     <env-entry-name>owner</env-entry-name>
     <env-entry-value>Neal</env-entry-value>
     <env-entry-type>java.lang.String</env-entry-type>
   </env-entry>
   <!-- /Environmental Variables Definitions -->


Thanks.
Neal



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>








--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>