src/java/Controllers/ProfileController.java
/**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
Handles the HTTP GET method.

@param request servlet request
@param response servlet response
@throws ServletException if a servlet-specific error occurs
@throws IOException if an I/O error occurs
Handles the HTTP GET method . @param request servlet request @param response servlet response @throws ServletException if a servlet - specific error occurs @throws IOException if an I / O error occurs
@Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        HttpSession session = request.getSession(false);
        List<Reservation> resevations = new ArrayList<Reservation>();
        ReservationDAO resevationDAO = new ReservationDAO();
        Hotel hotel = new Hotel();
        HotelDAO hotelDAO = new HotelDAO();
        User user = new User();
        UserDAO userDAO = new UserDAO();
        if (session == null || session.getAttribute("user_id") == null) {
            RequestDispatcher rd = request.getRequestDispatcher("views/404.jsp");
            rd.forward(request, response);
        } else {
            int userid = (Integer) session.getAttribute("user_id");
            user = userDAO.get(userid);
            resevations = resevationDAO.getAllWhere("user_id", userid);
            request.setAttribute("user", user);
            request.setAttribute("resevations", resevations);
            if (user.getUserType().equals("admin")) {
                RoomDAO roomDAO = new RoomDAO();
                List<Room> rooms = new ArrayList<Room>();
                RateDAO rateDAO = new RateDAO();
                List<UserRate> userRate = new ArrayList<UserRate>();
                hotel = hotelDAO.getAllWhere("user_id", userid).get(0);
                rooms = roomDAO.getAllWhere("hotel_id", hotel.getId());
                userRate = rateDAO.getAllInner("hotel_id", hotel.getId());
                String check_in = request.getParameter("check_in");
                String check_out = request.getParameter("check_out");
                resevations = searchDAO.getAllReservations(check_in, check_out, userid);
                String email = request.getParameter("email");
                String phoneNumber = request.getParameter("phone_number");
                List<User> usersSearch = searchDAO.getAllUsers(email, phoneNumber);
                request.setAttribute("hotel", hotel);
                request.setAttribute("rooms", rooms);
                request.setAttribute("rates", userRate);
                request.setAttribute("res", resevations);
                request.setAttribute("usersSearch", usersSearch);
            }
            RequestDispatcher rd = request.getRequestDispatcher("views/profile.jsp");
            rd.forward(request, response);
        }
    }
@ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { HttpSession session = request . getSession ( false ) ; List < Reservation > resevations = new ArrayList < Reservation > ( ) ; ReservationDAO resevationDAO = new ReservationDAO ( ) ; Hotel hotel = new Hotel ( ) ; HotelDAO hotelDAO = new HotelDAO ( ) ; User user = new User ( ) ; UserDAO userDAO = new UserDAO ( ) ; if ( session == null || session . getAttribute ( "user_id" ) == null ) { RequestDispatcher rd = request . getRequestDispatcher ( "views/404.jsp" ) ; rd . forward ( request , response ) ; } else { int userid = ( Integer ) session . getAttribute ( "user_id" ) ; user = userDAO . get ( userid ) ; resevations = resevationDAO . getAllWhere ( "user_id" , userid ) ; request . setAttribute ( "user" , user ) ; request . setAttribute ( "resevations" , resevations ) ; if ( user . getUserType ( ) . equals ( "admin" ) ) { RoomDAO roomDAO = new RoomDAO ( ) ; List < Room > rooms = new ArrayList < Room > ( ) ; RateDAO rateDAO = new RateDAO ( ) ; List < UserRate > userRate = new ArrayList < UserRate > ( ) ; hotel = hotelDAO . getAllWhere ( "user_id" , userid ) . get ( 0 ) ; rooms = roomDAO . getAllWhere ( "hotel_id" , hotel . getId ( ) ) ; userRate = rateDAO . getAllInner ( "hotel_id" , hotel . getId ( ) ) ; String check_in = request . getParameter ( "check_in" ) ; String check_out = request . getParameter ( "check_out" ) ; resevations = searchDAO . getAllReservations ( check_in , check_out , userid ) ; String email = request . getParameter ( "email" ) ; String phoneNumber = request . getParameter ( "phone_number" ) ; List < User > usersSearch = searchDAO . getAllUsers ( email , phoneNumber ) ; request . setAttribute ( "hotel" , hotel ) ; request . setAttribute ( "rooms" , rooms ) ; request . setAttribute ( "rates" , userRate ) ; request . setAttribute ( "res" , resevations ) ; request . setAttribute ( "usersSearch" , usersSearch ) ; } RequestDispatcher rd = request . getRequestDispatcher ( "views/profile.jsp" ) ; rd . forward ( request , response ) ; } }
Handles the HTTP <code>GET</code> method.
Handles the HTTP <code > GET< / code > method .