Thank you for the reply Jo�o.

I've tried the code with no success, all I got was:
javax.naming.NameNotFoundException: Name leaders.archive is not bound in this Context
...


My server.xml file has the following GlobalNamingResources:
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" debug="0"/>
<GlobalNamingResources>
<Environment description="This is a test!" name="leaders.archive" override="false" type="java.lang.String" value="LEADERS Archive"/>
<Environment name="simpleValue" override="true" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" scope="Shareable" type="org.apache.catalina.UserDatabase"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>


Do I need to create a ResourceLink in the application context in order to read a value in the GlobalNamingResources?

Thanks again,
Miguel Vieira

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:[EMAIL PROTECTED]
Sent: 25 September 2003 12:35
To: [EMAIL PROTECTED]
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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to