I'm trying to understand naming contexts and their implementations in
tomcat.....looking at the code below, we lookup the jndi resource
"jdbc/test"  When tomcat starts up, it parses the server.xml file.....It
finds:
        

                <Resource name="jdbc/test" auth="Container"
type="javax.sql.DataSource"/>
                        <ResourceParams name="jdbc/test">
                                <parameter>
                                        <name>factory</name>
                                        <value>org.apache.commons. 
        
dbcp.BasicDataSourceFactory</value>
                                </parameter>
                                .
                                .
                                .
Tomcat looks at this and adds a name value pair to a naming
context.....My question is about this naming context that tomcat
has......How can I add a name value pair to this same context?.....and
then how can I make a reference to that value?   Would I access it in
the same way the code below does?  (("java:/comp/env/"myRefernceName")
or ("java:/myReferenceName") ) I want to add other values to this very
same context....My basic idea is to have an xml file with all of the
properties for my webapp.. My webapp will read this config.xml file when
tomcat starts the application......this part will be another question
:)......and I want to lookup these properties using jndi.....my reason
for this is I want to be able to lookup certain application specific
properties (i.e. ldap stuff, jdbc stuff, constants, and such.....and I
know about adding jdbc, and ldap res-ref in the server.xml) much like a
myApp.properties file......Any ideas?  Does this question make
sense......


 

try {
        Context ctx = new InitialContext();

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

        DataSource ds =
(DataSource)ctx.lookup("java:comp/env/jdbc/test");
                        
        out.println ("DATASOURCE: " + ds);
                        
        conn = ds.getConnection();

        .
        .
        .
        }catch{......   


Thanx in advance
Russ

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to