To set your context path to / (the root context path), you need to use a Context deployment.
mywebapp.war
file.${jetty.home}/start.ini
file, and you see that it contains both
references to etc/jetty-webapps.xml
and etc/jetty-contexts.xml
.The WebAppProvider's role (see Using the WebApp Provider) is to look in the
${jetty.home}/webapps/
directory for any deployable applications (such as *.war), and deploy them onto a
context of the same name as the filename. For example, the WebAppProvider deploys
${jetty.home}/webapps/MyApp-2.4.war
into the context /MyApp-2.4
. There is also the special
root.war
reserved word that deploys into the context / . While this is the easiest deployment
mechanism, it sacrifices control over deployment specifics.
The ContextProvider's role (see ???) is to look in the
${jetty.home}/contexts/
directory for any jetty-xml formatted, deployable contexts. This deployment
mechanism gives you the maximum control over the deployment, as this XML file can control anything that is
ultimately resolved to an org.eclipse.jetty.server.handler.ContextHandler
base class, of which
WebAppContexts (WARs, servlets, etc.) are part. The most common use is to specify a WebAppContext-based XML file,
and control things such as what files and directories make up the web application, what temporary directory to use,
and even what Context Path to use.
To set the context path to / , follow these steps.
start.ini
.
That is, make sure that etc/jetty-context.xml
is present.${jetty.home}/contexts/mywebapp.xml
that declares the
<Set>/</Set>
option.etc/jetty-webapps.xml
present in your start.ini
, do
not put your mywebapp.war
in ${jetty.home}/webapps
because doing so causes the
WebAppProvider to also deploy the same webapp, and confuses your deployment.
${jetty.home}/contexts/test.xml
. Jetty loads the
${jetty.home}/webapps/test.war
via the ContextProvider's use of the
${jetty.home}/contexts/test.xml
into the / context path.Look at the logs:
2012-01-13 13:56:28.779:INFO:oejsh.ContextHandler:started o.e.j.w.WebAppContext{/,file:/tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/},/home/joakim /code/jetty/distros/jetty-distribution-7.6.0.RC3/webapps/test.war
That reveals that WebAppContext was Started on {/, (the root Context Path) It was using the temp/work
directory file: /tmp/jetty-0.0.0.0-8080-test.war-_-any-/webapp/
. It was using the web
application specified in
/home/joakim/code/jetty/distros/jetty-distribution-7.6.0.RC3/webapps/test.war.