Including configuration information from external XML files in the server.xml file

You can use the include element to include configuration information from an external XML file in the server.xml file.

If you have configuration information in an external XML file, you can use the include element to include the configuration information in the server.xml file. For example, if you have an XML file, simpleSecurity.xml, with the following content:
<server>    
 <quickStartSecurity userPassword="thePassword"/>
</server>
You can use the following method to include the configuration information in simpleSecurity.xml file in your server.xml file:
<server>
 <featureManager>
  <feature>servlet-3.0</feature>
 </featureManager> 
 <quickStartSecurity userName="theUser"/>
 <include location="simpleSecurity.xml"/>
</server>
The effective configuration is as follows:
<server>   
 <featureManager>
  <feature>servlet-3.0</feature>
 </featureManager> 
 <quickStartSecurity userName="theUser"/>
 <quickStartSecurity userPassword="thePassword"/>
</server>

Conflict handling

You can configure the onConflict attribute in the server.xml file to handle the value conflict between server.xml file and the external file. This attribute can be configured to one of the three values: Merge, Replace, and Ignore.

Merge
The values are merged together. Merge is the default value of the onConflict attribute and Merge is equivalent to the behavior that you get if you specify all of the conflicting elements in the server.xml file. In the previous example, there are two quickStartSecurity elements, and they are effectively merged into a single element. The effective configuration is as follows:
<quickStartSecurity userName="theUser" userPassword="thePassword"/>
For more information about how configuration elements are merged, see Configuration element merging rules.
Replace
The value from the included configuration file replaces the conflicting values in the server.xml file. In the previous example, the included quickStartSecurity element replaces the one from the server.xml file, so the effective configuration is as follows:
<quickStartSecurity userPassword="thePassword"/>
Ignore
The value from the included file is ignored. In the previous example, the quickStartSecurity element from the included file is ignored, so the effective configuration is as follows:
<quickStartSecurity userName="theUser"/>