3

I read that context.xml file (in Tomcat) is application specific. I have created two web projects from my netbeans IDE with Tomcat as the server.But I unable to find the application specific context.xml files. I have only found the context.xml inside the conf directory of Tomcat.

enter image description here

Where can I find the application specific context.xml files ?

Suhail Gupta
  • 22,386
  • 64
  • 200
  • 328

2 Answers2

2

Based on my experience and what i see from the documentation:

Context elements may be explicitly defined:
  • In the $CATALINA_BASE/conf/context.xml file: the Context element information will be loaded by all webapps.
  • In the $CATALINA_BASE/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host.

Taken from here

VirtualTroll
  • 3,077
  • 1
  • 30
  • 47
  • As you can see in the picture pasted above,I do not have the catalina directory there. In this case what do I do ? – Suhail Gupta Jul 20 '12 at 04:14
  • application specific `context.xml` isn't inside `META-INF/context.xml` ? – Suhail Gupta Jul 21 '12 at 05:31
  • The first option above is not application-specific. The second would be, for example, conf/Catalina/localhost/yourappname.xml. The file and its parent directories, if they don't yet exist, are created when you deploy the war. This approach lets you configure two instances of the same war differently. A third option is to use the context.xml inside the war itself. – usethe4ce Oct 21 '13 at 21:32
1

I noticed the link in the other answer is for the wrong version of Tomcat. Here is the correct documentation:

http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Defining_a_context

As you can see the options are different now from previous versions. In my experience the most common is options 1:

In an individual file at /META-INF/context.xml inside the application files.
Dave L.
  • 9,595
  • 7
  • 43
  • 69