protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        HttpSession session = request.getSession();
        request.setCharacterEncoding("UTF-8");
        User loggedIn = (User) session.getAttribute("loggedIn");

        if (!isLoggedIn(session)) {
            showJSP("index.jsp", request, response);
            return;
        }

        String idParam = request.getParameter("id");
        Game game = null;
        int id = 1;
        int gameid = 0;
        try {
            id = Integer.parseInt(idParam);
        } catch (Exception e) {
        }
        try {
            game = Game.getGame(id);
            gameid = game.getId();
            if (game.getUserID() != loggedIn.getID()) {
                setError("Stop trying to hack the database!", request);
                showJSP("index.jsp", request, response);
                return;
            }
        } catch (SQLException ex) {
            Logger.getLogger(GameServlet.class.getName()).log(Level.SEVERE, null, ex);
        }

        if (game != null) {
            List<Player> players = null;
            try {
                players = Player.getPlayers(gameid);
            } catch (SQLException ex) {
                Logger.getLogger(DeleteGameServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
            request.setAttribute("players", players);
            request.setAttribute("game", game);
            showJSP("game.jsp", request, response);
        } else {
            request.setAttribute("game", null);
            setError("The game was not found!", request);
            List<Game> games = null;
            try {
                games = Game.getGames(loggedIn.getID());
            } catch (SQLException ex) {
                Logger.getLogger(GameServlet.class.getName()).log(Level.SEVERE, null, ex);
            }
            request.setAttribute("games", games);
            showJSP("games.jsp", request, response);
        }
    }