From: Jérôme Benoit Date: Wed, 11 Apr 2018 12:40:36 +0000 (+0200) Subject: Add exo4 missing bits and exo10 code. X-Git-Url: https://git.piment-noir.org/?p=TD_webapps.git;a=commitdiff_plain;h=05e819e4ef0cd435debc3b9a4d8ff34c654878c3;hp=df7d30b6e2c4fe49f1e4e2d5be51d52778fd020d Add exo4 missing bits and exo10 code. Signed-off-by: Jérôme Benoit --- diff --git a/ROOT/exo10/WEB-INF/classes/date/Date.class b/ROOT/exo10/WEB-INF/classes/date/Date.class new file mode 100644 index 0000000..6e7c1ab Binary files /dev/null and b/ROOT/exo10/WEB-INF/classes/date/Date.class differ diff --git a/ROOT/exo10/WEB-INF/classes/date/DateRefresh.class b/ROOT/exo10/WEB-INF/classes/date/DateRefresh.class new file mode 100644 index 0000000..8f1a417 Binary files /dev/null and b/ROOT/exo10/WEB-INF/classes/date/DateRefresh.class differ diff --git a/ROOT/exo10/WEB-INF/classes/form/Checkbox.class b/ROOT/exo10/WEB-INF/classes/form/Checkbox.class new file mode 100644 index 0000000..8858592 Binary files /dev/null and b/ROOT/exo10/WEB-INF/classes/form/Checkbox.class differ diff --git a/ROOT/exo10/WEB-INF/classes/form/Login.class b/ROOT/exo10/WEB-INF/classes/form/Login.class new file mode 100644 index 0000000..854675d Binary files /dev/null and b/ROOT/exo10/WEB-INF/classes/form/Login.class differ diff --git a/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class b/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class index 24e3e97..ffc0db3 100644 Binary files a/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class and b/ROOT/exo10/WEB-INF/classes/hello/HelloWorld.class differ diff --git a/ROOT/exo10/WEB-INF/src/date/Date.java b/ROOT/exo10/WEB-INF/src/date/Date.java new file mode 100644 index 0000000..b29fab4 --- /dev/null +++ b/ROOT/exo10/WEB-INF/src/date/Date.java @@ -0,0 +1,43 @@ +package date; + +// Import required java libraries +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name="Date", urlPatterns={"/Date"}) +// Extend HttpServlet class +public class Date extends HttpServlet { + + private java.util.Date d; + private Integer count; + + public void init() throws ServletException { + // Do required initialization + d = new java.util.Date(); // Date at init time, do not change + count = 0; + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Set response content type + response.setContentType("text/html"); + + // Actual logic goes here. + count++; + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println("Date " + d.toString()); + out.println("
"); + out.println("GET call number " + count); + out.println(""); + out.println(""); + } + + public void destroy() { + count = 0; + } +} diff --git a/ROOT/exo10/WEB-INF/src/date/DateRefresh.java b/ROOT/exo10/WEB-INF/src/date/DateRefresh.java new file mode 100644 index 0000000..24cbd5f --- /dev/null +++ b/ROOT/exo10/WEB-INF/src/date/DateRefresh.java @@ -0,0 +1,44 @@ +package date; + +// Import required java libraries +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name="DateRefresh", urlPatterns={"/DateRefresh"}) +// Extend HttpServlet class +public class DateRefresh extends HttpServlet { + + //private java.util.Date d; + //private Integer count; + + public void init() throws ServletException { + // Do required initialization + //d = new java.util.Date(); // DateRefresh at init time, do not change + //count = 0; + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Set response content type + response.setContentType("text/html"); + response.addHeader("Refresh", "1"); + + // Actual logic goes here. + //count++; + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println("Date " + new java.util.Date().toString()); + //out.println("
"); + //out.println("GET call number " + count); + out.println(""); + out.println(""); + } + + public void destroy() { + //count = 0; + } +} diff --git a/ROOT/exo10/WEB-INF/src/form/Checkbox.java b/ROOT/exo10/WEB-INF/src/form/Checkbox.java new file mode 100644 index 0000000..7a55915 --- /dev/null +++ b/ROOT/exo10/WEB-INF/src/form/Checkbox.java @@ -0,0 +1,42 @@ +package form; + +// Import required java libraries +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name="Checkbox", urlPatterns={"/Checkbox"}) +// Extend HttpServlet class +public class Checkbox extends HttpServlet { + + private String[] players; + + public void init() throws ServletException { + // Do required initialization + players = new String[4]; + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Set response content type + response.setContentType("text/html"); + + String[] players = request.getParameterValues("player"); + + // Actual logic goes here. + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + for (int i = 0; i < players.length; i++) { + out.println(players[i] + "
"); + } + out.println(""); + out.println(""); + } + + public void destroy() { + + } +} diff --git a/ROOT/exo10/WEB-INF/src/form/Login.java b/ROOT/exo10/WEB-INF/src/form/Login.java new file mode 100644 index 0000000..4f4f8d1 --- /dev/null +++ b/ROOT/exo10/WEB-INF/src/form/Login.java @@ -0,0 +1,63 @@ +package form; + +// Import required java libraries +import java.io.*; +import javax.servlet.*; +import javax.servlet.http.*; +import javax.servlet.annotation.WebServlet; + +@WebServlet(name="Login", urlPatterns={"/Login"}) +// Extend HttpServlet class +public class Login extends HttpServlet { + + private String login; + private String password; + + public void init() throws ServletException { + // Do required initialization + login = new String(); + password = new String(); + } + + public void doGet(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Set response content type + response.setContentType("text/html"); + + // Actual logic goes here. + login = request.getParameter("login"); + password = request.getParameter("password"); + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println("Login: " + login); + out.println("
"); + out.println("Password: " + password); + out.println(""); + out.println(""); + } + + public void doPost(HttpServletRequest request, HttpServletResponse response) + throws ServletException, IOException { + + // Set response content type + response.setContentType("text/html"); + + // Actual logic goes here. + login = request.getParameter("login"); + password = request.getParameter("password"); + PrintWriter out = response.getWriter(); + out.println(""); + out.println(""); + out.println("Login: " + login); + out.println("
"); + out.println("Password: " + password); + out.println(""); + out.println(""); + } + + public void destroy() { + + } +} diff --git a/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java b/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java index 446f823..f25597f 100644 --- a/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java +++ b/ROOT/exo10/WEB-INF/src/hello/HelloWorld.java @@ -14,7 +14,7 @@ public class HelloWorld extends HttpServlet { public void init() throws ServletException { // Do required initialization - message = "Hello World"; + message = "Bienvenue au cours d'applications Web"; } public void doGet(HttpServletRequest request, HttpServletResponse response) diff --git a/ROOT/exo10/form.html b/ROOT/exo10/form.html new file mode 100644 index 0000000..087835a --- /dev/null +++ b/ROOT/exo10/form.html @@ -0,0 +1,14 @@ + + + + +
+ Login:
+
+ Password:
+

+ +
+ + + diff --git a/ROOT/exo10/formcheckbox.html b/ROOT/exo10/formcheckbox.html new file mode 100644 index 0000000..afc6e0d --- /dev/null +++ b/ROOT/exo10/formcheckbox.html @@ -0,0 +1,19 @@ + + + + +
+ Quel joueur préférez-vous ?
+ +
+ +
+ +
+ +

+ +
+ + + diff --git a/ROOT/exo4/WEB-INF/src/bonjour/hello.java b/ROOT/exo4/WEB-INF/src/bonjour/hello.java new file mode 100644 index 0000000..9970d64 --- /dev/null +++ b/ROOT/exo4/WEB-INF/src/bonjour/hello.java @@ -0,0 +1,7 @@ +package bonjour; + +public class hello { + public String affiche() { + return "Bonjour"; + } +} diff --git a/ROOT/exo4/WEB-INF/web.xml b/ROOT/exo4/WEB-INF/web.xml new file mode 100644 index 0000000..7f339c8 --- /dev/null +++ b/ROOT/exo4/WEB-INF/web.xml @@ -0,0 +1,9 @@ + + + + + diff --git a/ROOT/exo4/hello.jsp b/ROOT/exo4/hello.jsp new file mode 100644 index 0000000..11fcb52 --- /dev/null +++ b/ROOT/exo4/hello.jsp @@ -0,0 +1,9 @@ +<%@ page import="bonjour.hello, javax.servlet.*" %> + + +<% + hello h = new hello(); + //out.print(h.afficher()); +%> + + diff --git a/ROOT/exo7/cookie-form.html b/ROOT/exo7/cookie-form.html index 10bbcaa..aba78e8 100644 --- a/ROOT/exo7/cookie-form.html +++ b/ROOT/exo7/cookie-form.html @@ -1,3 +1,4 @@ +