Add exo8 code.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 11 Apr 2018 13:47:37 +0000 (15:47 +0200)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Wed, 11 Apr 2018 13:47:37 +0000 (15:47 +0200)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
ROOT/exo7/form.jsp
ROOT/exo7/nextpage.jsp
ROOT/exo7/saveinfos.jsp
ROOT/exo7/viewcookie.jsp
ROOT/exo8/META-INF/context.xml [new file with mode: 0644]
ROOT/exo8/WEB-INF/classes/user/UserData.class [new file with mode: 0644]
ROOT/exo8/WEB-INF/src/user/UserData.java [new file with mode: 0644]
ROOT/exo8/getname-form.html [new file with mode: 0644]
ROOT/exo8/saveinfos.jsp [new file with mode: 0644]

index 96c73e61c13e0b5beb45e42fa5d13618c6ee03d6..87b0b522531058493d7282a816e0ee4e30024124 100644 (file)
@@ -1,3 +1,4 @@
+<meta charset="UTF-8">
 <html>
 <body>
 
 <html>
 <body>
 
index f54b811eac7ed3a6246f97201c95ea3f103639ca..c1b19242e9251d73b389ac671c683eb189e759d3 100644 (file)
@@ -1,3 +1,4 @@
+<meta charset="UTF-8">
 <html>
     <body>
         Bonjour <% out.print(session.getAttribute("firstname")); %>
 <html>
     <body>
         Bonjour <% out.print(session.getAttribute("firstname")); %>
index 11b0f65a18e0bd61fa44c29769c9c48810773626..37da3fd1a4f5f61946ec0ab6baaf8463cfbc1a35 100644 (file)
@@ -10,7 +10,7 @@ session.setAttribute("address", address);
 session.setAttribute("age", age);
 session.setAttribute("work", work);
 %>
 session.setAttribute("age", age);
 session.setAttribute("work", work);
 %>
-
+<meta charset="UTF-8">
 <html>
     <body>
         <a href="nextpage.jsp">Continue</a>
 <html>
     <body>
         <a href="nextpage.jsp">Continue</a>
index 2a705f6f8843802fad4bca5cba2d09d4493466a9..4335f3573e9f187a0fae2e727fb154f98a889104 100644 (file)
@@ -1,5 +1,5 @@
 <% Cookie[] cookies = request.getCookies(); %>
 <% Cookie[] cookies = request.getCookies(); %>
-
+<meta charset="UTF-8">
 <html>
     <body>
         Bonjour <br>
 <html>
     <body>
         Bonjour <br>
diff --git a/ROOT/exo8/META-INF/context.xml b/ROOT/exo8/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/exo8/WEB-INF/classes/user/UserData.class b/ROOT/exo8/WEB-INF/classes/user/UserData.class
new file mode 100644 (file)
index 0000000..6fa20c2
Binary files /dev/null and b/ROOT/exo8/WEB-INF/classes/user/UserData.class differ
diff --git a/ROOT/exo8/WEB-INF/src/user/UserData.java b/ROOT/exo8/WEB-INF/src/user/UserData.java
new file mode 100644 (file)
index 0000000..f015477
--- /dev/null
@@ -0,0 +1,40 @@
+package user;
+public class UserData {
+    String firstname;
+    String lastname;
+    String email;
+    Integer age;
+
+    public void setFirstname(String value) {
+        firstname = value;
+    }
+
+    public void setLastname(String value) {
+        lastname = value;
+    }
+
+    public void setEmail(String value) {
+        email = value;
+    }
+
+    public void setAge(Integer value) {
+        age = value;
+    }
+
+    public String getFirstname() {
+        return firstname;
+    }
+
+    public String getLastname() {
+        return lastname;
+    }
+
+    public String getEmail() {
+        return email;
+    }
+
+    public Integer getAge() {
+        return age;
+    }
+
+}
diff --git a/ROOT/exo8/getname-form.html b/ROOT/exo8/getname-form.html
new file mode 100644 (file)
index 0000000..3b69fcc
--- /dev/null
@@ -0,0 +1,18 @@
+<meta charset="UTF-8">
+<html>
+<body>
+
+<form method="POST" action="saveinfos.jsp">
+  First name:<br>
+  <input type="text" name="firstname"><br>
+  Last name:<br>
+  <input type="text" name="lastname"><br>
+  Email:<br>
+  <input type="email" name="email"><br>
+  Age:<br>
+  <input type="text" name="age" size="3"><br><br>
+  <input type="submit" value="Submit">
+</form>
+
+</body>
+</html>
diff --git a/ROOT/exo8/saveinfos.jsp b/ROOT/exo8/saveinfos.jsp
new file mode 100644 (file)
index 0000000..8ddc1a9
--- /dev/null
@@ -0,0 +1,12 @@
+<%@ page contentType="text/html" pageEncoding="UTF-8" %>
+<jsp:useBean id="user" class="user.UserData" scope="session" />
+<jsp:setProperty name="user" property="*"/>
+<meta charset="UTF-8">
+<html>
+    <body>
+        Prénom: <%= user.getFirstname() %><br>
+        Nom: <%= user.getLastname() %><br>
+        Email: <%= user.getEmail() %><br>
+        Age: <%= user.getAge() %><br>
+    </body>
+</html>