Jetty/Howto/Deploy Web Applications
Jetty can deploy web applications as WAR files (packed or unpacked), as provided or with overridden configuration, and with static or hot deployment.
Jetty scans its $JETTY_HOME/webapps directory at startup for web applications to deploy:
- It deploys the file foo.war as a webapp at context /foo.
- It deploys the directory foo/ at context /foo. If the directory has a WEB-INF subdirectory, Jetty treats it as a servlet webapp, otherwise Jetty serves it only as static content.
- If both a foo.war and a foo/ directory exist, Jetty uses the one with the most recent last-modified date.
- If the webapp is called root.war or the directory is called root/ then Jetty deploys it at the / context.
- If the contextXmlDir option is used and a foo.xml file exists in that dir, the WebAppProvider defers to the Contexts Provider for actual webapp deployment.
See also older (but mostly relevant) Jetty-6 WebAppDeployer documentation.
Jetty scans the $JETTY_HOME/contexts directory at runtime for context.xml files that describe either:
- a standard WAR file (or directory), plus additional configuration.
- a custom Jetty context.
See also older (but mostly relevant) Jetty-6 ContextDeployer documentation.
Jetty Maven Plugin
If you develop your web application as a Maven project, you can deploy it in Jetty with mvn jetty:run using the Jetty Maven Plugin.
Maven lets you build your web applications by overlaying on other template web applications (for example, Cometd) and manages the transitive dependencies needed to populate WEB-INF/lib.
OSGi web application bundle
Using Embedded Jetty
You can also deploy web applications into embedded Jetty, either via direct configuration or via configuration of a deployer. For an example see the Embedding Jetty Tutorial.