protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        System.out.println("MSSServlet: processRequest()");
        response.setContentType("text/html;charset=UTF-8");
        try (PrintWriter out = response.getWriter()) {
            RequestDispatcher dispatcher;
            ServletContext servletContext = getServletContext();
            String page = request.getPathInfo();
            page = page.substring(1);
            System.out.println("[MSSServlet] startPage: " + page + ", logged in as: " + loggedInAs);
            // DONE
            if (page.equals("login")) {
                if (isLoggedIn()) {
                    request.setAttribute("studentInfo", getStudentInfo(matricNumber));
                    page = "profile";
                }
            } // DONE 
            else if (page.equals("loginUser")) {
                if (checkStudentLogin(request)) {
                    request.setAttribute("studentInfo", getStudentInfo(matricNumber));
                    page = "profile";
                } else {
                    request.setAttribute("message", "Incorrect matriculation number or password!");
                    page = "login";
                }
            } else if (page.equals("logout")) {
                loggedInAs = "";
                page = "index";
            } else if (!isLoggedIn()) {
                page = "login";
            } //DONE
            else if (page.equals("profile")) {
                if (isLoggedIn()) {
                    request.setAttribute("studentInfo", getStudentInfo(matricNumber));
                    page = "profile";
                } else {
                    page = "login";
                }
                page = "profile";
            } // DONE
            else if (page.equals("updateEmail")) {
                if (updateEmail(request)) {
                    System.out.println("MSSServlet: Successfully updated email");
                    request.setAttribute("studentInfo", getStudentInfo(matricNumber));
                    request.setAttribute("message", "Email changed successfully!");
                }
                if (isLoggedIn()) {
                    request.setAttribute("studentData", getStudentInfo(matricNumber));
                }
                page = "profile";
            } // DONE
            else if (page.equals("updatePassword")) {
                if (updatePassword(request)) {
                    System.out.println("MSSServlet: Successfully changed password");
                    request.setAttribute("studentInfo", getStudentInfo(matricNumber));
                    request.setAttribute("message", "Password changed successfully!");
                }
                if (isLoggedIn()) {
                    request.setAttribute("studentData", getStudentInfo(matricNumber));
                }
                page = "profile";
            } // DONE
            else if (page.equals("modules")) {
                System.out.println("MSS: modules page");
            } else if (page.equals("search")) {
                String keyword = request.getParameter("keyword");
                list = mrsb.moduleSearch(keyword);
                request.setAttribute("data", list);
                request.setAttribute("keyword", keyword);
                page = "modResults";
            } // DONE
            else if (page.equals("registerModule")) {
                registerStudentToModule(request);
                page = "modules";
            } //DONE
            else if (page.equals("tutorials")) {
                list = mrsb.getRegisteredModules(matricNumber);
                // System.out.println(list);
                request.setAttribute("data", list);
            } //DONE
            else if (page.equals("registerTutorial")) {
                registerStudentToTutorial(request);
                page = "modules";
            } //DONE
            else if (page.equals("timetable")) {
                request.setAttribute("data", dataForTimetable());
                page = "timetable";
            }
            else if (page.equals("appeals")) {
                getAppeals();
                request.setAttribute("data", list);
                page = "appeals";
            }
            dispatcher = servletContext.getNamedDispatcher(page);
            System.out.println("[MSSServlet] Dispatched: " + page + ", logged in as: " + loggedInAs);
            if (dispatcher == null) {
                dispatcher = servletContext.getNamedDispatcher("error");
            }
            dispatcher.forward(request, response);
        } catch (Exception ex) {
            log("Exception in MSSServlet.processRequest()");
            ex.printStackTrace();
            response.sendRedirect("/MSS/");
        }
    }