What is resource-ref in web.xml used for?

Posted by Denise on Stack Overflow See other posts from Stack Overflow or by Denise
Published on 2010-05-22T11:54:52Z Indexed on 2010/05/22 12:00 UTC
Read the original article Hit count: 351

Filed under:
|
|

Hi everyone,

I'm just wondering when/why you would define a resource-ref element in your web.xml file?

I would have thought that it would be defined in your web/app server using JNDI and then look up the JNDI reference in your Java code?

The resource-ref definition seems a bit redundant to me and I can't think of when it might be useful. Example:

<resource-ref>
  <description>Primary database</description>
  <res-ref-name>jdbc/primaryDB</res-ref-name>
  <res-type>javax.sql.DataSource</res-type>
  <res-auth>CONTAINER</res-auth>
</resource-ref>

Thanks!

© Stack Overflow or respective owner

Related posts about java

Related posts about web.xml