Monday, 13 August 2012

What is the context.xml file in a Web Application?

When one creates a default maven web application (from the corresponding archetype), a file called context.xml is automatically be created in /src/main/webapp/META-INF/ if the selected server is Apache Tomcat.

For example:
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/MyApplication"/>
From the Tomcat documentation, this file represents the application withing Tomcat. It contains a very important information: the application path. In other words:

When multiple applications are deployed on Tomcat, users' requests are sent to the proper application by checking each application's path. Longer matching paths have priority on shorter paths.

This file can be used to set some application configuration too (see the bottom of the Tomcat documentation page mentioned above) or a JNDI resource such as a data source for example.

No comments:

Post a comment