--- /dev/null
+package hello;
+
+// Import required java libraries
+import java.io.*;
+import javax.servlet.*;
+import javax.servlet.http.*;
+import javax.servlet.annotation.WebServlet;
+
+@WebServlet(name="HelloWorld", urlPatterns={"/HelloWorld"})
+// Extend HttpServlet class
+public class HelloWorld extends HttpServlet {
+
+ private String message;
+
+ public void init() throws ServletException {
+ // Do required initialization
+ message = "Hello World";
+ }
+
+ public void doGet(HttpServletRequest request, HttpServletResponse response)
+ throws ServletException, IOException {
+
+ // Set response content type
+ response.setContentType("text/html");
+
+ // Actual logic goes here.
+ PrintWriter out = response.getWriter();
+ out.println("<html>");
+ out.println("<body>");
+ out.println("<h1>" + message + "</h1>");
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ public void destroy() {
+ // do nothing.
+ }
+}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
+ http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
+ version="3.1">
+
+</web-app>