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

 
(5 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
{{Jetty Reference
 
{{Jetty Reference
| introduction = xxx
+
| introduction =  
 +
 
 +
{{Jetty Redirect|http://www.eclipse.org/jetty/documentation/current/jetty-xml-usage.html}}
 +
 
 +
Jetty provides an XML-based configuration. It is based on Java's Reflection API. Classes in the java.lang.reflect represent Java methods and classes, such that you can instantiate objects and invoke their methods based on their names and argument types. Behind the scenes, Jetty's XML config parser translates the XML elements and attributes into Reflection calls.
 +
 
 
| body =
 
| body =
 
}}
 
}}
 
  
 
== Using <tt>jetty.xml</tt> ==
 
== Using <tt>jetty.xml</tt> ==
Line 11: Line 15:
 
  java -jar start.jar etc/jetty.xml
 
  java -jar start.jar etc/jetty.xml
  
{{note|Configuration files|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>.}}
+
{{note|Configuration files|If you start Jetty without specifying a configuration file, Jetty automatically locates and uses the default installation <tt>jetty.xml</tt> file. Therefore <tt>java -jar start.jar</tt> is equivalent to <tt>java -jar start.jar etc/jetty.xml</tt>.}}
  
 
== Multiple Configuration Files ==
 
== 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.
+
You are not limited to one configuration file; you can 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 the instance you want to configure. Each server ID in a configuration file creates a new server instance within the same JVM. If you use the same ID across multiple configuration files, those configurations are all applied to the same server.
 
+
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 ==
+
== Setting Parameters in 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:
+
You can set parameters in configuration files either with 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 is not specified:
  
 
<source lang="xml">
 
<source lang="xml">

Latest revision as of 15:41, 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-usage.html


Jetty provides an XML-based configuration. It is based on Java's Reflection API. Classes in the java.lang.reflect represent Java methods and classes, such that you can instantiate objects and invoke their methods based on their names and argument types. Behind the scenes, Jetty's XML config parser translates the XML elements and attributes into Reflection calls.

Using jetty.xml

To use jetty.xml, specify it as a configuration file when running Jetty.

java -jar start.jar etc/jetty.xml
Note.png
Configuration files
If you start Jetty without specifying a configuration file, Jetty automatically locates and uses the default installation jetty.xml file. Therefore java -jar start.jar is equivalent to java -jar start.jar etc/jetty.xml.


Multiple Configuration Files

You are not limited to one configuration file; you can 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 the instance you want to configure. Each server ID in a configuration file creates a new server instance within the same JVM. If you use the same ID across multiple configuration files, those configurations are all applied to the same server.

Setting Parameters in Configuration Files

You can set parameters in configuration files either with 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 is 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

Back to the top