Jetty has moved!
Jetty is a project at the Eclipse Foundation.
Homepage:http://www.eclipse.org/jetty
Downloads: http://download.eclipse.org/jetty/
Documentation:http://www.eclipse.org/jetty/documentation/current/
About:http://www.eclipse.org/jetty/about.php
Jetty Powered:http://www.eclipse.org/jetty/powered/
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

The override web.xml file

The webdefault.xml file supplies configuration of web.xml file elements that would otherwise be repetitive and onerous to set up for every web application, such as setting up mime-type mappings, JSP servlet-mappings etc. It is applied BEFORE the webapp's own WEB-INF/web.xml file. Generally, it is convenient for all webapps deployed in a jetty instance to share the same webdefault.xml file, however, it is certainly possible to provide differentiated webdefault.xml files for individual web applications.

A common need is to be able to deploy the same unchanged webapp/war into different environments, but also to have that webapp customized for that environment. To some extent, changing configuration in the jetty.xml will help with this, as that file does not form part of the webapp, and so therefore can be changed per deployment.

However, there are some things you might want to change that jetty.xml cannot help you with: for example, servlet init-params and context init-params. Using webdefault.xml won't help you either, because it is applied first so cannot override values inside the webapps web.xml.

The solution is to use an override web.xml file. This is another whole or partial web.xml file that resides externally to the webapp, and is applied AFTER the webapp's WEB-INF/web.xml file and can therefore override or add new elements.

Configuring an override web.xml file for jetty standalone

There is an example of applying an override web.xml file in $jetty.home/contexts/test.xml. To apply an override to a single webapp:

In code this is:

Configuring an override web.xml file for the jetty maven plugin

Use the <overrideWebXml> element as follows:

There is more information on configuring the jetty maven plugin here.

  • No labels
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery