In the previous section, we created a Java project with a
web subproject. The
web project has a simple servlet. To execute the servlet, we must create a WAR file and deploy the WAR file to a servlet container, such as Tomcat or Jetty. You can learn more about Jetty at http://www.eclipse.org/jetty/. With the Jetty plugin, we can run our
web project from the command line in a Jetty web container. We don't have to install Jetty on our computer, we only need to apply the Jetty plugin to our project. The plugin will take care of configuring Jetty and starting the web container. If everything is okay, we can open a web browser and access our servlet.
To add the Jetty plugin to our
web project, let's create a new
build.gradle file in the web directory. Here, we will use the
apply() method to add the Jetty plugin to the project:
apply plugin: 'jetty'
The plugin adds the following tasks to our project:
jettyStop. The following table shows the different...