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

From Eclipsepedia

Jump to: navigation, search
(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...)
 
Line 13: Line 13:
  
 
==== Custom <tt>webdefault.xml</tt> for One Webapp ====
 
==== Custom <tt>webdefault.xml</tt> for One Webapp ====
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]].
+
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]].
  
 
<source lang="xml">
 
<source lang="xml">

Revision as of 23:18, 25 June 2009



Contents

Introduction

webdefault.xml is a file which is applied to a web application before the application's own WEB-INF/web.xml. 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 $(jetty.home)/etc/webdefault.xml for the Jetty distribution.

Using webdefault.xml / Customizing webdefault.xml

Using webdefault.xml

The distribution's webdefault.xml can be found at $JETTY_HOME/etc/webdefault.xml. 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 webdefault.xml will automatically be used.

Jetty Standalone

Custom webdefault.xml for One Webapp

You can modify any of the settings inside the version of webdefault.xml shipped in the Jetty distribution, and apply this custom configuration to an individual web application, by configuring it through the webapp's jetty-web.xml.

<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.

Custom webdefault.xml 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 hot deployer or the static deployer in your Jetty/References/jetty.xml.

<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>

Jetty Maven Plugin

Additional Resources

  • Syntax Reference - in-depth reference for Jetty-specific configuration XML syntax
  • jetty.xml - configuration file for configuring the entire server