Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.
Difference between revisions of "Jetty/Reference/jetty.xml"
m |
|||
Line 34: | Line 34: | ||
== Parameterizing Configuration Files == | == 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 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"> | <source lang="xml"> |
Revision as of 23:18, 24 June 2009
Contents
Introduction
jetty.xml is the default configuration file for Jetty, located at $JETTY_HOME/etc/jetty.xml. The Jetty configuration format is a simple mapping from XML to Java. With this format you can call the methods defined in the Javadoc to configure a server.
This document offers an overview for using the jetty.xml configuration file. For a detailed walk through for writing your own jetty.xml file, see Jetty/Tutorials/jetty.xml. For a more in-depth look at the syntax, see Syntax Reference.
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>
Using jetty.xml
To use jetty.xml, specify it as a configuration file when running Jetty.
java -jar start.jar etc/jetty.xml
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 <Configure>
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 <SystemProperty>
) or properties files (using <Property>
) passed via the command line. For example, this code in jetty.xml allows the port to be defined on the command line, falling back onto 8080 if the port was not specified:
<Set name="port"><SystemProperty name="jetty.port" default="8080"/></Set>
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