Question
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
protected void processRequest(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
// we need to use session in this case
HttpSession session = request.getSession();
// setup some varialbe
String [][] game = null; // game matrix
String player = "X"; // player
// get the current gamre from session
if (session.getAttribute("game") != null) {
game = (String[][]) session.getAttribute("game");
} else {
// init it if it isn't there
game = new String[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
game[i][j] = "";
}
}
}...