O'Reilly logo

Java 9 Programming By Example by Peter Verhas

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Hello world servlet

Before getting into the technical details, let's create an extremely simple hello world servlet. To do it, we setup a Gradle project with the build file, build.gradle, the servlet class in the file, src/main/java/packt/java9/by/example/mastermind/servlet/HelloWorld.java, and last but not least, we have to create the file src/main/webapp/WEB-INF/web.xml. The gradle.build file will look the following:

apply plugin: 'java'  apply plugin: 'jetty'    repositories {      jcenter()  }    dependencies {      providedCompile "javax.servlet:javax.servlet-api:3.1.0"  }    jettyRun {      contextPath '/hello'  }

The Gradle build file uses two plugins, java and jetty. We have already used the java plugin in the previous chapter. The jetty plugin ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required