think of <resource-env-ref> as the interface and the <Resource> as the implementation. Does it make more sense now? Your application get information through the interface. This interface is the same on all J2EE compliant containers. Each container provides its own implementation backing this, though.


In Tomcat's case, I think it will actually work without the <resource-env-ref>. However, this is just Tomcat being nice about it. It should probably be strict and require it to make sure people are developing apps that aren't dependent on container specifics.

Jake

At 08:33 PM 8/19/2003 +0530, you wrote:
hi all,

Why do we need the tag <resource-env-ref> in web.xml. What is the purpose of
this.
I saw some example where that was trying to register Datasource as JNDI
resource
in server.xml  and in web.xml. Why do we need at two places?

In server.xml:
  <Resource name="jdbc/myDB" auth="Container"
    type="javax.sql.DataSource"/>
  <ResourceParams name="jdbc/myDB">
    <parameter>
      <name>factory</name>
      <value>org.objectweb.jndi.DataSourceFactory</value>
    </parameter>
    <!-- configured by default for PostgreSQL, just change the values
         to set it for your database
    -->
    <parameter><name>username</name><value>mojo</value></parameter>
    <parameter><name>password</name><value>jojo</value></parameter>
    <parameter>
      <name>driverClassName</name>
      <value>org.postgresql.Driver</value>
    </parameter>
    <parameter>
      <name>url</name>
      <value>jdbc:postgresql://localhost/javatest</value>
    </parameter>
  </ResourceParams>


In web.xml: <resource-env-ref> <description> DB Connection </description> <resource-env-ref-name> jdbc/myDB </resource-env-ref-name> <resource-env-ref-type> javax.sql.DataSource </resource-env-ref-type> </resource-env-ref>


I tried this, it was working fine. Then I removed the tag <resource-env-ref> from web.xml and It was working fine. Even I tested if there is any difference in loading on startup or on first request. There is no difference. In the two scenarios the resource was loaded when it was requested for the first time. Can you please let me know why is it required to define <resource-env-ref> in web.xml.

thanx
Venkat




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


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



Reply via email to