protected void doPost(HttpServletRequest request,
                          HttpServletResponse response) throws
                                                        IOException,
                                                        ServletException,
                                                        IllegalStateException {
        String forwardPath = PATH_INDEX;
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        int paramMapSize = request.getParameterMap().size();

        if (COMPUTE.equals(request.getParameter(COMPUTE)) && username != null
                                                          && password != null
                                                          && paramMapSize ==
                                                             PARAMS) {
            try {
                NINJA gpaNINJA = (NINJA) this.getServletContext()
                                             .getAttribute(ATTRIBUTE_MODEL);
                Student student = gpaNINJA.compute(username, password);

                request.setAttribute("student", student);
                forwardPath = PATH_GPA;
            } catch (HttpStatusException e) {
                e.printStackTrace();
                String ERROR_MSG = e.getMessage();

                if (ERROR_MSG == null || ERROR_MSG.startsWith(E1)) {
                    /*
                     * York site that handles transcripts goes down every now
                     * and then after midnight for a few hours
                     */
                    request.setAttribute("ERROR_MSG", "Looks like the York " +
                                         "site is down");
                    response.sendError(HttpServletResponse.SC_BAD_GATEWAY);
                }
                else if (ERROR_MSG.startsWith(E2)) {
                    request.setAttribute("ERROR_MSG", "Login failed - " +
                                         "incorrect username or password");
                    response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
                }

                return;
            } catch (Exception e) {
                e.printStackTrace();
                response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
                return;
            }
        }

        RequestDispatcher dispatcher = this.getServletContext()
                                           .getRequestDispatcher(forwardPath);
        dispatcher.forward(request, response);
    }