Add exo10 code.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 11 Apr 2018 10:26:53 +0000 (12:26 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 11 Apr 2018 10:26:53 +0000 (12:26 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ROOT/exo10/META-INF/context.xml [new file with mode: 0644]
ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class [new file with mode: 0644]
ROOT/exo10/WEB-INF/src/hello/HelloWorld.java [new file with mode: 0644]
ROOT/exo10/WEB-INF/web.xml [new file with mode: 0644]

diff --git a/ROOT/exo10/META-INF/context.xml b/ROOT/exo10/META-INF/context.xml
new file mode 100644 (file)
index 0000000..00e2ff6
--- /dev/null
@@ -0,0 +1,2 @@
+<Context path=""
+       antiResourceLocking="false" />
diff --git a/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class b/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class
new file mode 100644 (file)
index 0000000..24e3e97
Binary files /dev/null and b/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class differ
diff --git a/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java b/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java
new file mode 100644 (file)
index 0000000..446f823
--- /dev/null
@@ -0,0 +1,38 @@
+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.
+   }
+}
diff --git a/ROOT/exo10/WEB-INF/web.xml b/ROOT/exo10/WEB-INF/web.xml
new file mode 100644 (file)
index 0000000..7f339c8
--- /dev/null
@@ -0,0 +1,9 @@
+<?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>