Possible Duplicate:
What is resource-ref in web.xml used for?
I added the following tag in context.xml
of Tomcat :
<Resource name="jdbc/PollDatasource" auth="Container" type="javax.sql.DataSource"
driverClassName="org.apache.derby.jdbc.ClientDriver" url="jdbc:derby://localhost:1527/poll_database;create=true"
username="suhail" password="suhail" maxActive="20" maxIdle="10" maxWait="-1" />
The above tag gets read,when the server is started and the application is deployed. I also added the following in web.xml
of my project :
<resource-ref>
<description>my connection</description>
<res-ref-name>jdbc/PollDatasource</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
What is the above tag meant for ?
Because when i write a statement like:
DataSource ds = (DataSource)envContext.lookup("jdbc/PollDatasource")
doesn't it directly look into the context.xml
of the server ? I know I am wrong.In this case please help me understand what is the resource-ref
tag meant for in web.xml
?