Add exo4 missing bits and exo10 code.
[TD_webapps.git] / ROOT / exo10 / WEB-INF / src / form / Checkbox.java
... / ...
CommitLineData
1package form;
2
3// Import required java libraries
4import java.io.*;
5import javax.servlet.*;
6import javax.servlet.http.*;
7import javax.servlet.annotation.WebServlet;
8
9@WebServlet(name="Checkbox", urlPatterns={"/Checkbox"})
10// Extend HttpServlet class
11public class Checkbox extends HttpServlet {
12
13 private String[] players;
14
15 public void init() throws ServletException {
16 // Do required initialization
17 players = new String[4];
18 }
19
20 public void doPost(HttpServletRequest request, HttpServletResponse response)
21 throws ServletException, IOException {
22
23 // Set response content type
24 response.setContentType("text/html");
25
26 String[] players = request.getParameterValues("player");
27
28 // Actual logic goes here.
29 PrintWriter out = response.getWriter();
30 out.println("<html>");
31 out.println("<body>");
32 for (int i = 0; i < players.length; i++) {
33 out.println(players[i] + "<br>");
34 }
35 out.println("</body>");
36 out.println("</html>");
37 }
38
39 public void destroy() {
40
41 }
42}