From: Jérôme Benoit Date: Wed, 11 Apr 2018 10:26:53 +0000 (+0200) Subject: Add exo10 code. X-Git-Url: https://git.piment-noir.org/?p=TD_webapps.git;a=commitdiff_plain;h=df7d30b6e2c4fe49f1e4e2d5be51d52778fd020d Add exo10 code. Signed-off-by: Jérôme Benoit --- diff --git a/ROOT/exo10/META-INF/context.xml b/ROOT/exo10/META-INF/context.xml new file mode 100644 index 0000000..00e2ff6 --- /dev/null +++ b/ROOT/exo10/META-INF/context.xml @@ -0,0 +1,2 @@ + diff --git a/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class b/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class new file mode 100644 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 index 0000000..446f823 --- /dev/null +++ b/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java @@ -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(""); + out.println(""); + out.println("

" + message + "

"); + out.println(""); + out.println(""); + } + + 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 index 0000000..7f339c8 --- /dev/null +++ b/ROOT/exo10/WEB-INF/web.xml @@ -0,0 +1,9 @@ + + + + +