Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Jetty/Reference/webdefault.xml"

(New page: {{Jetty Reference | introduction = <tt>webdefault.xml</tt> is a file which is applied to a web application ''before'' the application's own <tt>WEB-INF/web.xml</tt>. It is used to save a w...)
 
 
(26 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Jetty Reference
 
{{Jetty Reference
| introduction = <tt>webdefault.xml</tt> is a file which is applied to a web application ''before'' the application's own <tt>WEB-INF/web.xml</tt>. It is used to save a web application from having to define a lot of house-keeping and container-specific elements in their own web.xml files, and uses the same syntax as a web.xml file. It can be found in <tt>$(jetty.home)/etc/webdefault.xml</tt> for the Jetty distribution.
+
| introduction =  
  
| body =
+
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/webdefault-xml.html}}
  
== Using <tt>webdefault.xml</tt> / Customizing <tt>webdefault.xml</tt> ==
+
The <tt>webdefault.xml</tt> file saves web applications from having to define a lot of house-keeping and container-specific elements in their own <tt>web.xml</tt> files. For example, you can use it to set up mime-type mappings and JSP servlet-mappings. Jetty applies <tt>webdefault.xml</tt> to a web application ''before'' the application's own <tt>WEB-INF/web.xml</tt>, which means that it cannot override values inside the webapp's <tt>web.xml</tt>. It uses the [[Jetty/Reference/jetty.xml_syntax|<tt>jetty.xml</tt> syntax]].  Generally, it is convenient for all webapps in a Jetty instance to share the same <tt>webdefault.xml</tt> file. However, it is certainly possible to provide differentiated <tt>webdefault.xml</tt> files for individual web applications.
  
=== Using <tt>webdefault.xml</tt> ===
+
The <tt>webdefault.xml</tt> file is located in <tt>$(jetty.home)/etc/webdefault.xml</tt>.
  
The distribution's <tt>webdefault.xml</tt> can be found at <tt>$JETTY_HOME/etc/webdefault.xml</tt>. You may specify another configuration file to be used for specific webapps, or for all webapps (see below). If you do not specify an alternate defaults descriptor, the distribution's <tt>webdefault.xml</tt> will automatically be used.
+
| body =
  
=== Jetty Standalone ===
+
== Using <tt>webdefault.xml</tt> ==
  
==== Custom <tt>webdefault.xml</tt> for One Webapp ====
+
You can specify a custom configuration file to use for specific webapps, or for all webapps. If you do not specify an alternate defaults descriptor,  Jetty automatically uses <tt>webdefault.xml</tt>.
You can modify any of the settings inside the version of <tt>webdefault.xml</tt> shipped in the Jetty distribution and apply this custom configuration to an individual web application by configuring it through the webapp's [[Jetty/References/jetty-web.xml|jetty-web.xml]].
+
 
 +
=== Creating a Custom <tt>webdefault.xml</tt> for One WebApp ===
 +
You can specify a custom <tt>webdefault.xml</tt> for an individual web application in that webapp's [[Jetty/Reference/jetty-web.xml|jetty-web.xml]] as follows:
  
 
<source lang="xml">
 
<source lang="xml">
Line 37: Line 39:
 
</source>
 
</source>
  
Alternatively, you can use a classloader to find the resource representing your custom <tt>webdefault.xml</tt>.
+
Alternatively, you can use a [[Jetty/Reference/Jetty_Classloading|classloader]] to find the resource representing your custom <tt>webdefault.xml</tt>.
  
==== Custom <tt>webdefault.xml</tt> for Multiple Webapps ====
+
=== Creating a Custom <tt>webdefault.xml</tt> for Multiple WebApps ===
If you want to apply the same custom webdefault.xml to a number of webapps, then supply the path to the file to the [[ContextDeployer|hot deployer]] or the [[WebAppDeployer|static deployer]] in your <tt>[[Jetty/References/jetty.xml]]</tt>.
+
If you want to apply the same custom <tt>webdefault.xml</tt> to a number of webapps, provide the path to the file in <tt>[[Jetty/Reference/jetty.xml|jetty.xml]]</tt> either to the hot deployer ([[Jetty/Feature/ContextDeployer|Context Provider]]) or the static deployer ([[Jetty/Feature/WebAppDeployer|WebAppProvider]]). For example:
  
 
<source lang="xml">
 
<source lang="xml">
Line 53: Line 55:
 
</source>
 
</source>
  
=== Jetty Maven Plugin ===
+
=== Using the Jetty Maven Plugin ===
 
+
 
+
  
 +
Similarly, for the [[Jetty/Feature/Jetty Maven Plugin|Jetty Maven Plugin]], you provide a customized <tt>webdefault.xml</tt> file for your webapp as follows:
 +
<source lang="xml">
 +
<project>
 +
    ...
 +
    <plugins>
 +
        <plugin>
 +
            ...
 +
            <artifactId>jetty-maven-plugin</artifactId>
 +
            <configuration>
 +
                <webAppConfig>
 +
                  ...
 +
                  <defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
 +
                </webAppConfig>
 +
            </configuration>
 +
        </plugin>
 +
        ...
 +
    </plugins>
 +
    ...
 +
</project>
 +
</source>
  
 
| more =  
 
| more =  
* [[Jetty/References/Syntax Reference|Syntax Reference]] - in-depth reference for Jetty-specific configuration XML syntax
+
* [[Jetty/Reference/jetty-web.xml|web.xml Reference]]–reference information for <tt>web.xml</tt> files
* [[Jetty/References/jetty.xml|jetty.xml]] - configuration file for configuring the entire server
+
* [[Jetty/Reference/override-web.xml|<tt>override-web.xml</tt>]]–a web.xml-formatted file, applied after the webapp's web.xml
 +
* [[Jetty/Reference/jetty.xml|jetty.xml Reference]]–more information about <tt>jetty.xml</tt>
 
}}
 
}}

Latest revision as of 15:43, 23 April 2013



Introduction

Warning2.png
Jetty 7 and Jetty 8 are now EOL (End of Life)




THIS IS NOT THE DOCUMENTATION YOU ARE LOOKING FOR!!!!!






All development and stable releases are being performed with Jetty 9 and Jetty 10.






This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub






Direct Link to updated documentation: http://www.eclipse.org/jetty/documentation/current/webdefault-xml.html


The webdefault.xml file saves web applications from having to define a lot of house-keeping and container-specific elements in their own web.xml files. For example, you can use it to set up mime-type mappings and JSP servlet-mappings. Jetty applies webdefault.xml to a web application before the application's own WEB-INF/web.xml, which means that it cannot override values inside the webapp's web.xml. It uses the jetty.xml syntax. Generally, it is convenient for all webapps 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.

The webdefault.xml file is located in $(jetty.home)/etc/webdefault.xml.

Using webdefault.xml

You can specify a custom configuration file to use for specific webapps, or for all webapps. If you do not specify an alternate defaults descriptor, Jetty automatically uses webdefault.xml.

Creating a Custom webdefault.xml for One WebApp

You can specify a custom webdefault.xml for an individual web application in that webapp's jetty-web.xml as follows:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
  ...
  <!-- Set up the absolute path to the custom webdefault.xml -->
  <Set name="defaultsDescriptor">/my/path/to/webdefault.xml</Set>
  ...
</Configure>

The equivalent in code is:

import org.eclipse.jetty.webapp.WebAppContext;
 
    ...
 
    WebAppContext wac = new WebAppContext();
    ...
    //Set up the absolute path to the custom webdefault.xml.
    wac.setDefaultsDescriptor("/my/path/to/webdefault.xml");
    ...

Alternatively, you can use a classloader to find the resource representing your custom webdefault.xml.

Creating a Custom webdefault.xml for Multiple WebApps

If you want to apply the same custom webdefault.xml to a number of webapps, provide the path to the file in jetty.xml either to the hot deployer (Context Provider) or the static deployer (WebAppProvider). For example:

<Configure class="org.eclipse.jetty.webapp.WebAppContext">
    ...
    <New class="org.eclipse.jetty.deploy.WebAppDeployer">
        ...
        <Set name="defaultsDescriptor">/my/path/to/webdefault.xml</Set>
    </New>
    ...
</Configure>

Using the Jetty Maven Plugin

Similarly, for the Jetty Maven Plugin, you provide a customized webdefault.xml file for your webapp as follows:

<project>
    ...
    <plugins>
        <plugin>
            ...
            <artifactId>jetty-maven-plugin</artifactId>
            <configuration>
                <webAppConfig>
                  ...
                  <defaultsDescriptor>/my/path/to/webdefault.xml</defaultsDescriptor>
                </webAppConfig>
            </configuration>
        </plugin>
        ...
    </plugins>
    ...
</project>

Additional Resources

Back to the top