For the purpose of deploying web applications to Jetty, there are two types of resources that can be deployed:
-
Standard Web Application Archives, in the form of
*.war
files or web application directories, defined by the Servlet specification. Their deployment is described in this section. -
Jetty context XML files, that allow you to customize the deployment of standard web applications, and also allow you use Jetty components, and possibly custom components written by you, to assemble your web applications. Their deployment is described in this section.
A standard Servlet web application is packaged in either a *.war
file or in a directory with the structure of a *.war
file.
Note
|
Recall that the structure of a
|
To deploy a standard web application, you need to enable the deploy
module (see the deploy
module complete definition here).
$ java -jar $JETTY_HOME/start.jar --add-module=deploy
link:jetty[role=include]
The deploy
module creates the $JETTY_BASE/webapps
directory, the directory where *.war
files or web application directories should be copied so that Jetty can deploy them.
Note
|
The Whether these web applications are served via clear-text HTTP/1.1, or secure HTTP/1.1, or secure HTTP/2, or HTTP/3 (or even all of these protocols) depends on whether the correspondent Jetty modules have been enabled. Refer to the section about protocols for further information. |
Now you need to copy a web application to the $JETTY_BASE/webapps
directory, and you can use one of the demos shipped with Jetty:
$ java -jar $JETTY_HOME/start.jar --add-module=demo-simple
The $JETTY_BASE
directory is now:
$JETTY_BASE ├── resources │ └── jetty-logging.properties ├── start.d │ ├── deploy.ini │ └── http.ini └── webapps └── demo-simple.war
Now start Jetty:
$ java -jar $JETTY_HOME/start.jar
link:jetty[role=include]
Note the highlighted line that logs the deployment of demo-simple.war
.
Now you can access the web application by pointing your browser to http://localhost:8080/demo-simple
.
If you want to customize the deployment of your web application, for example by specifying a contextPath
different from the file/directory name, or by specifying JNDI entries, or by specifying virtual hosts, etc. read this section.