<%@ page language="java" import ="java.util.*" import="java.math.*" %> TicTacToe

TicTacToe with JavaBean

<% // Check for a "Reset" button click if (request.getParameter("reset") != null) { game.reset(); } %> <% // Check for a game button click for (int r=0; r<3; r++) { for (int c=0; c<3; c++) { if (request.getParameter("B" + r + c) != null) { game.handleClick(r, c); } } } %>
<% // output the game board for (int r=0; r<3; r++) { out.println(""); for (int c=0; c<3; c++) { out.println(""); } out.println(""); } %>
<% // display winner if (!game.getWinner().equals("")) { out.println("

" + game.getWinner() + " Won!

"); } %>