You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Miguel Vieira <mi...@bookmarc.pt> on 2003/09/25 13:35:12 UTC

Accessing GlobalNamingResources

Hi,

I'm using Tomcat 4.1.19 and I'd like to know if it's possible to access 
the GlobalNamingResources, defined in server.xml, from a servlet, 
without creating a ResourceLink in the servlet's context?

Thanks,
Miguel Vieira


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


RE: Accessing GlobalNamingResources

Posted by Joao Medeiros <jo...@ntlworld.com>.
Miguel,

 

I'm assuming you want to access the values as defined for a given
parameter in your server.xml or in your web.xml files depending on
whether you want them defined globally or per application.

 

Try the folling code in your jsp file and replace the parameter name
with the appropriate one.

 

<<BEGIN CODE SNIPET>>

   String my_var = "";

   try

   {

      InitialContext initCtx      = new InitialContext();

      if(initCtx == null) throw new Exception("Boom - No Context");

      //Context envContext = (Context) initialContext.lookup
("java:comp/env");

      Context envCtx              =
(Context)initCtx.lookup("java:comp/env");

              my_var            = (String)
envCtx.lookup("my_parameter_name");

   }

   catch(Exception e) 

   {

      out.println(e.getMessage());

      e.printStackTrace();

   }

<<END CODE SNIPET>>

 

/JM

 

-----Original Message-----
From: Miguel Vieira [mailto:miguel@bookmarc.pt] 
Sent: 25 September 2003 12:35
To: tomcat-user@jakarta.apache.org
Subject: Accessing GlobalNamingResources

 

Hi,

 

I'm using Tomcat 4.1.19 and I'd like to know if it's possible to access 

the GlobalNamingResources, defined in server.xml, from a servlet, 

without creating a ResourceLink in the servlet's context?

 

Thanks,

Miguel Vieira

 

 

---------------------------------------------------------------------

To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org

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