| 1 | package form; |
| 2 | |
| 3 | // Import required java libraries |
| 4 | import java.io.*; |
| 5 | import javax.servlet.*; |
| 6 | import javax.servlet.http.*; |
| 7 | import javax.servlet.annotation.WebServlet; |
| 8 | |
| 9 | @WebServlet(name="Checkbox", urlPatterns={"/Checkbox"}) |
| 10 | // Extend HttpServlet class |
| 11 | public 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 | } |