Version: 9.4.5.v20170502 |
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 for sponsored feature development
Table of Contents
This chapter discusses various options for configuring Jetty contexts.
The context path is the prefix of a URL path that is used to select the context(s) to which an incoming request is passed. Typically a URL in a Java servlet server is of the format http://hostname.com/contextPath/servletPath/pathInfo
, where each of the path elements can be zero or more / separated elements.
If there is no context path, the context is referred to as the root context.
The root context must be configured as /
but is reported as the empty string by the servlet API getContextPath()
method.
How you set the context path depends on how you deploy the web application (or ContextHandler
).
If you run Jetty from code as an embedded server (see Embedding), setting the context path is a matter of calling the setContextPath
method on the ContextHandler
instance (or WebAppContext
instance).
If a web application is deployed using the WebAppProvider of the DeploymentManager without an XML IoC file, then the name of the WAR file is used to set the context path:
/myapp
/
/
and a virtual host of "foobar"If a web application is deployed using the WebAppProvider
of the DeploymentManager
with an XML IoC file to configure the context, then the setContextPath
method can be called within that file.
For example:
<Configure class="org.eclipse.jetty.webapp.WebAppContext">
<Set name="contextPath">/test</Set>
...
</Configure>