Skip to main content
Jump to: navigation, search


< Jetty‎ | Howto


Jetty 7 and Jetty 8 are now EOL (End of Life)


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:

The context path is the prefix of a URL path that is used to select the web application to which an incoming request is routed. Typically a URL in a Java servlet server is of the format, where each of the path elements may be zero or more / separated elements. If there is no context path, the context is referred to as the root context.

How you set the context path depends on how you deploy the web application (or ContextHandler):

Embedded Deployment

If you run Jetty from code as an embedded server, setting the context path is a matter of calling the setContextPath method on the ContextHandler instance (or WebAppContext instance).

Context Deployment

If you deploy the webapplication/context from the context deployer/provider, you set the contextPath within the context.xml file.

 <Configure class="org.eclipse.jetty.webapp.WebAppContext">
   <Set name="contextPath">/foo</Set>

Webapp Deployment

If you deploy the web application from the webapp deployer/provider, by default the name of the WAR file forms the context path. So if the file is called foobar.war, the context path is /foobar. There is a special case for webapps called root.war which are mapped to the root / context.

You can also set the context path for webapps by embedding a WEB-INF/jetty-web.xml file in the WAR. This is not a preferred method.

Back to the top