2

I have a query related to the contents of element in context.xml file for Jndi look up and the resource-ref element in web.xml . The Tomcat 5.5 reference gives an overview of the Resource element.

  1. As per the reference above , the valid attributes for Resource element are auth,description,name,scope,type but we do include driverClassName , url, username, password etc and a same is in the sample in the Tomcat docs. So is the explanation in the former link wrong?

  2. The reference states that the inclusion of the <Resource> element in context.xml file is equivalent to the resource-ref element in web.xml . If so , can we give the driverClassName , url, username, password and the remaining attributes in web.xml and give the context.xml file a miss ? I don't think we can . So why is the reference so confusing?

skaffman
  • 398,947
  • 96
  • 818
  • 769
Aravind A
  • 9,507
  • 4
  • 36
  • 45

1 Answers1

1
  1. Yes, it looks like the first reference is not comprehensive on all the attributes of the Resource element, the second one is much more comprehensive.

  2. It is stated a little wrongly - instead of saying that the resource is equivalent to the resource-ref element in web.xml it should have said that the resource-ref in web.xml maps to the resource element in context.xml. It is a way to provide a local reference with its own name for the resource within a web application, and then during deployment time to map this internal resource name to a real container specific jndi resource - What is resource-ref in web.xml used for?

Community
  • 1
  • 1
Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125