Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery

Part II. Jetty Configuration Guide

Table of Contents

4. Configuring Contexts
Setting a Context Path
Setting Context Path to / (root)
Creating Custom Error Pages
Serving a WebApp from a Particular Port
5. Deploying Jetty
Webapp Layout
Using the Deployment Manager
Setting Deployment Bindings
Hot Deployment
Deploying WebApps
Using the Context Provider
Using the WebApp Provider
6. Configuring JSP Support
Configuring JSP
7. Jetty Logging
Configuring Jetty Request Logs
Sifting Logs with Logback
8. Configuring WebSockets
Configuring WebSockets
9. Security Topics
<chapter> <title>Configuring Jetty Connectors</title> <para></para> <para> <emphasis>THIS CHAPTER HAS NOT YET BEEN UPDATED FOR JETTY-9</emphasis> </para> <para></para> <para>This chapter discusses various options for configuring Jetty connectors.</para>

Configuring Connectors

As listed in the Contents above, Jetty provides several types of connectors that allow you to tailor the server setup to suit your circumstances.

SelectChannelConnector

This connector uses efficient NIO buffers with a non-blocking threading model. Jetty uses Direct NIO buffers, and allocates threads only to connections with requests. Synchronization simulates blocking for the servlet API, and any unflushed content at the end of request handling is written asynchronously. See the javadoc. This connector is best used when there are a many connections that have idle periods.

When used with [[Jetty/Feature/Continuations|Continuations]], //TODO xref// threadless waits are supported. When a filter or servlet calls getEvent on a Continuation, a runtime exception is thrown to allow the thread to exit the current request handling. Jetty catches this exception and does not send a response to the client. Instead Jetty releases the thread and places the Continuation on the timer queue. If the Continuation timeout expires, or its resume method is called, then Jetty again allocates a thread to the request, and the request retries. The limitation of this approach is that request content is not available on the retried request, thus if possible it should be read after the Continuation or saved as a request attribute or as the associated object of the Continuation instance.

SocketConnector

This connector implements a traditional blocking IO and threading model. Jetty uses Normal JRE sockets and allocates a thread per connection. Jetty allocates large buffers to active connections only. You should use this Connector only if NIO is not available. See the javadoc.

SslSelectChannelConnector

This is an SSL connector that uses NIO. For more information about its configuration, see [[Jetty/Reference/SSL Connectors|SSL Connector Reference]]. //TODO xref//See also the javadoc.

SslSocketConnector

This is a blocking IO connector that supports SSL. See the javadoc.

Ajp13SocketConnector

This connector implements the AJP13 protocol. See [[Jetty/Howto/Configure AJP13|How to Configure Ajp13]] //TODO xref//for more information, and also take a look at [[JETTY/Howto/Configure mod_proxy|How to Configure mod_proxy]] //TODOxref// for alternatives to using the AJP13 protocol. See also the javadoc.

Configuration Options

You can fine tune your connector configuration using the following parameters.

Table 3. Connector Configuration Parameters

ParameterDescription
acceptorsThe number of threads dedicated to accepting incoming connections.
acceptQueueSizeNumber of connection requests that can be queued up before the operating system starts to send rejections.
acceptorPrioritySets the priority of the acceptor threads relative to the other threads.
confidentialPortThe port to redirect to if there is a security constraint of CONFIDENTIAL.
confidentialSchemehttps by default
forwardedIf true use <tt>hostHeader</tt>or else check the headers for retrieving information from the original request to control what <tt>ServletRequest#getServerName()</tt>and <tt>ServletRequest#getServerPort()</tt>and <tt>ServletRequest#getRemoteAddr()</tt>return. Default is false. See [[Jetty/Howto/Configure mod_proxy|How to Configure mod_proxy]].
forwardedHostHeaderThe forwarded <tt>Host</tt>header to use. Default is <tt>X-Forwarded-Host</tt>. This value is used only if <tt>forwarded</tt>is true.
forwardedServerHeaderThe forwarded server name header to use. Default is <tt>X-Forwarded-Server</tt>. This value is used only if <tt>forwarded</tt>is true.
forwardedForHeaderThe forwarded for header to use. Default is <tt>X-Forwarded-For</tt>. This value is used only if <tt>forwarded</tt>is true.
headerBufferSizeSets the size of the buffer for request and response headers. An idle connection at most has one buffer of this size allocated. Default is 4K.
hostHeaderSet a forced valued for the <tt>Host</tt>header to control what <tt>ServletRequest#getServerName()</tt>and <tt>ServletRequest#getServerPort()</tt>return. This value is used only if <tt>forwarded</tt>is true.
hostThe particular interface to listen on. If not set or 0.0.0.0, Jetty listens on <tt>port</tt>on all interfaces.
integralPortThe port to redirect to if there is a security constraint of INTEGRAL.
lowResourcesConnectionsSets the number of connections, which if exceeded places this connector in a low resources state. This is not an exact measure as the connection count is averaged over the select sets. When in a low resources state, different idle timeouts can apply on connections. See <tt>lowResourcesMaxIdleTime</tt>.
lowResourcesMaxIdleTimeSets the period in ms that a connection is allowed to be idle when this there are more than <tt>lowResourcesConnections</tt>connections. This allows the server to rapidly close idle connections in order to gracefully handle high load situations.
maxIdleTimeSet the maximum Idle time for a connection, which roughly translates to the Socket.setSoTimeout(int) call, although with NIO implementations other mechanisms may be used to implement the timeout. The max idle time is applied: when waiting for a new request to be received on a connection; when reading the headers and content of a request; when writing the headers and content of a response. Jetty interprets this value as the maximum time between some progress being made on the connection. So if a single byte is read or written, then the timeout (if implemented by Jetty) is reset. However, in many instances, the reading/writing is delegated to the JVM, and the semantic is more strictly enforced as the maximum time a single read/write operation can take. Note that as Jetty supports writes of memory-mapped file buffers, a write may take many 10s of seconds for large content written to a slow device.
nameThe name of the connector. Can be used to make a WebAppContext respond only to requests on the named connector via the <tt>WebAppContext.setConnectorNames(String[])</tt>method
portThe port to listen on. See also <tt>host</tt>.
requestBufferSizeSets the size of the content buffer for receiving requests. These buffers are used only for active connections that have requests with bodies that do not fit within the header buffer (see <tt>headerBufferSize</tt>). Default is 8K.
responseBufferSizeSets the size of the content buffer for sending responses. These buffers are used only for active connections that are sending responses with bodies that will not fit within the header buffer. Default is 32K.
resolveNamesIf true, request IP addresses will be resolved to host names.
reuseAddressTrue if the the server socket will be opened in SO_REUSEADDR mode.
soLingerTimeSets SO_LINGER on the connection socket. Disabled by default.
statsOnIf true, enables statistics collection on connections. See [[Jetty/Feature/Statistics|Statistics]].
useDirectBuffersFor nio connectors, determines whether direct byte buffers will be used or not. The default is true.
threadPoolSets the thread pool instance. By default this is the thread pool set on the org.eclipse.jetty.server.Server instance, and is a org.eclipse.jetty.util.thread.QueuedThreadPool instance.

</chapter>
See an error or something missing?
Contribute to this documentation at Github!