--- /dev/null
+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("<html>");
+ out.println("<body>");
+ out.println("Date " + d.toString());
+ out.println("<br>");
+ out.println("GET call number " + count);
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ public void destroy() {
+ count = 0;
+ }
+}
--- /dev/null
+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("<html>");
+ out.println("<body>");
+ out.println("Date " + new java.util.Date().toString());
+ //out.println("<br>");
+ //out.println("GET call number " + count);
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ public void destroy() {
+ //count = 0;
+ }
+}
--- /dev/null
+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("<html>");
+ out.println("<body>");
+ for (int i = 0; i < players.length; i++) {
+ out.println(players[i] + "<br>");
+ }
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ public void destroy() {
+
+ }
+}
--- /dev/null
+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("<html>");
+ out.println("<body>");
+ out.println("Login: " + login);
+ out.println("<br>");
+ out.println("Password: " + password);
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ 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("<html>");
+ out.println("<body>");
+ out.println("Login: " + login);
+ out.println("<br>");
+ out.println("Password: " + password);
+ out.println("</body>");
+ out.println("</html>");
+ }
+
+ public void destroy() {
+
+ }
+}
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)
--- /dev/null
+<meta charset="UTF-8">
+<html>
+<body>
+
+<form method="POST" action="/Login">
+ Login:<br>
+ <input type="text" name="login"><br>
+ Password:<br>
+ <input type="password" name="password"><br><br>
+ <input type="submit" value="Submit">
+</form>
+
+</body>
+</html>
--- /dev/null
+<meta charset="UTF-8">
+<html>
+<body>
+
+<form method="POST" action="/Checkbox">
+ Quel joueur préférez-vous ?<br>
+ <input type="checkbox" id="Zidane" name="player" value="Zidane">
+ <label for="Zidane">Zidane</label><br>
+ <input type="checkbox" id="Maradona" name="player" value="Maradona">
+ <label for="Maradona">Maradona</label><br>
+ <input type="checkbox" id="Platini" name="player" value="Platini">
+ <label for="Platini">Platini</label><br>
+ <input type="checkbox" id="Pelé" name="player" value="Pelé">
+ <label for="Pelé">Pelé</label><br><br>
+ <input type="submit" value="Submit">
+</form>
+
+</body>
+</html>
--- /dev/null
+package bonjour;
+
+public class hello {
+ public String affiche() {
+ return "Bonjour";
+ }
+}
--- /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>
--- /dev/null
+<%@ page import="bonjour.hello, javax.servlet.*" %>
+<html>
+<body>
+<%
+ hello h = new hello();
+ //out.print(h.afficher());
+%>
+</body>
+</html>
+<meta charset="UTF-8">
<html>
<body>