title: What are steps followed in the look-up? what is looked first web.xml or context.xml?
body: <p>How does a look-up like :</p>
  
  <pre><code>Context envContext = (Context)initContext.lookup("java:comp/env");
  DataSource ds = (DataSource)envContext.lookup("jdbc/MyDatasource");
  </code></pre>
  
  <p>proceed ?</p>
  
  <p>I mean to say how is the <em>name</em> <code>MyDataSource</code> searched and in the end what is returned ? </p>
  
  <p>There are two entries added to connect to the database. One in the <code>WEB-INF/web.xml</code> which is :</p>
  
  <pre><code>&lt;resource-ref&gt;
  &lt;description&gt;my connection&lt;/description&gt;
  &lt;res-ref-name&gt;jdbc/MyDatasource&lt;/res-ref-name&gt;
  &lt;res-type&gt;javax.sql.DataSource&lt;/res-type&gt;
  &lt;res-auth&gt;Container&lt;/res-auth&gt;
  </code></pre>
  
  <p></p>
  
  <p>and the other added in the <code>META-INF/context.xml</code> which is :</p>
  
  <pre><code>&lt;Resource name="jdbc/MyDatasource" auth="Container" type="javax.sql.DataSource"
   driverClassName="org.apache.derby.jdbc.ClientDriver"
   url="jdbc:derby://localhost:1527/My Database;create=true"
   username="me" password="me"
   maxActive="20" maxIdle="10" maxWait="-1" /&gt;
  </code></pre>
  
  <p>How does these 2 entries help in the look up ? </p>
  
  <p>What is looked first : <code>web.xml</code> or <code>context.xml</code> ? </p>
  
  <p>Please explain the whole process in the look up.</p>