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/jetty.xml"

 
(5 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
{{Jetty Reference
 
{{Jetty Reference
| introduction = <tt>jetty.xml</tt> is the default configuration file for Jetty, located at <tt>$JETTY_HOME/etc/jetty.xml</tt>. The Jetty configuration format is a simple mapping from XML to Java. With this format you can call the methods defined in the [http://download.eclipse.org/jetty/stable-7/apidocs/ Javadoc] to configure a server.
+
| introduction =  
  
This document offers an overview for using the <tt>jetty.xml</tt> configuration file. For a detailed walk through for writing your own jetty.xml file, see the [[Jetty/Tutorial/jetty.xml|jetty.xml Tutorial]]. For a more in-depth look at the syntax, see the [[Jetty/Reference/jetty.xml Syntax|jetty.xml Syntax Reference]].  
+
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/jetty-xml-config.html}}
 +
 
 +
<tt>jetty.xml</tt> is the default configuration file for Jetty, typically located at <tt>$JETTY_HOME/etc/jetty.xml</tt>.  Usually the jetty.xml configures:
 +
* the Server class (or subclass if extended) and global options
 +
* a ThreadPool (min & max thread)
 +
* connectors (ports, timeouts, buffer sizes, protocol, etc.)
 +
* the handler structure (default handlers and/or a contextHandlerCollections, etc.)
 +
* the deployment manager that scans for and deploys webapps and contexts
 +
* login services that provides authentication checking
 +
* a request log
 +
 
 +
Not all Jetty features are configured in <tt>jetty.xml</tt>. There are several optional configuration files that share the same format as <tt>jetty.xml</tt> and, if specified, concatenate to it.  These configuration files are also stored in <tt>$JETTY_HOME/etc/</tt>, and examples of them are in [http://dev.eclipse.org/viewsvn/index.cgi/jetty/trunk/jetty-server/src/main/config/etc/?root=RT_JETTY SVN Repository].  The selection of which configuration files to use is controlled by [[Jetty/Feature/Start.jar|start.jar]] and the process of merging configuration is described in [[Jetty/Reference/jetty.xml_usage|jetty.xml usage]].
  
 
| body =  
 
| body =  
Line 17: Line 28:
 
</Configure>
 
</Configure>
 
</source>
 
</source>
 
== Using <tt>jetty.xml</tt> ==
 
 
To use <tt>jetty.xml</tt>, specify it as a configuration file when running Jetty.
 
 
java -jar start.jar etc/jetty.xml
 
 
{{note|If you start up Jetty without specifying a configuration file, Jetty will automatically locate and use the default installation jetty.xml file. Therefore <tt>java -jar start.jar</tt> is equivalent to <tt>java -jar start.jar etc/jetty.xml</tt>.}}
 
 
== Multiple Configuration Files ==
 
 
You are not limited to one configuration file; you may use multiple configuration files when running Jetty, and Jetty will configure the appropriate server instance.
 
 
The id of the server in the <code><Configure></code> tag specifies which instance you wish to configure. Each server id in a configuration file creates a new Server instance within the same JVM. If the same id is used across multiple configuration files, those configurations are all applied to the same server.
 
 
== Parameterizing Configuration Files ==
 
 
The configuration files may be parameterized with either system properties (using <code><SystemProperty></code>) or properties files (using <code><Property></code>) passed via the command line. For example, this code in <tt>jetty.xml</tt> allows the port to be defined on the command line, falling back onto <var>8080</var> if the port was not specified:
 
 
<source lang="xml">
 
  <Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
 
</source>
 
 
Then you modify the port while running Jetty by using this command:
 
java -Djetty.port=8888 -jar start.jar etc/jetty.xml
 
 
An example of defining both system properties and properties files from the command line:
 
java -Djetty.port=8888 -jar start.jar myjetty.properties etc/jetty.xml etc/other.xml
 
  
 
== Examples ==
 
== Examples ==
Line 51: Line 34:
  
 
| more =  
 
| more =  
* [[Jetty/Tutorial/jetty.xml|jetty.xml Tutorial]] - detailed tutorial which walks you through writing your own version of jetty.xml
+
* [[Jetty/Tutorial/jetty.xml|jetty.xml Tutorial]]–detailed tutorial that walks you through writing your own version of jetty.xml
* [[Jetty/Reference/jetty.xml Syntax|jetty.xml Syntax Reference]] - in-depth reference for Jetty-specific configuration XML syntax
+
* [[Jetty/Reference/jetty.xml syntax|jetty.xml Syntax Reference]]–in-depth reference for Jetty-specific configuration XML syntax
* [[Jetty/Reference/jetty-web.xml|jetty-web.xml]] - configuration file for configuring a specific webapp
+
* [[Jetty/Reference/jetty-web.xml|jetty-web.xml]]–configuration file for configuring a specific webapp
  
 
}}
 
}}

Latest revision as of 15:42, 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/jetty-xml-config.html


jetty.xml is the default configuration file for Jetty, typically located at $JETTY_HOME/etc/jetty.xml. Usually the jetty.xml configures:

  • the Server class (or subclass if extended) and global options
  • a ThreadPool (min & max thread)
  • connectors (ports, timeouts, buffer sizes, protocol, etc.)
  • the handler structure (default handlers and/or a contextHandlerCollections, etc.)
  • the deployment manager that scans for and deploys webapps and contexts
  • login services that provides authentication checking
  • a request log

Not all Jetty features are configured in jetty.xml. There are several optional configuration files that share the same format as jetty.xml and, if specified, concatenate to it. These configuration files are also stored in $JETTY_HOME/etc/, and examples of them are in SVN Repository. The selection of which configuration files to use is controlled by start.jar and the process of merging configuration is described in jetty.xml usage.

Root Element

jetty.xml configures an instance of the Jetty org.eclipse.jetty.server.Server.

<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
 
<Configure id="Server" class="org.eclipse.jetty.server.Server">
 ...
</Configure>

Examples

$JETTY_HOME/etc contains the default jetty.xml, as well as other sample configuration files (jetty-*.xml) which can be passed to the server via the command line.

Additional Resources

Back to the top