src/java/Controllers/SearchController.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);
        if (session == null || session.getAttribute("user_id") == null) 
        {
            RequestDispatcher rd = request.getRequestDispatcher("views/login.jsp");  
            rd.forward(request, response);
        }
        List<Hotel> hotels = new ArrayList<Hotel>();
        SearchDAO searchDAO = new SearchDAO();
        String checkInDate = request.getParameter("check_in");
        String checkOutDate = request.getParameter("check_out");
        String adults = request.getParameter("adults");
        String children = request.getParameter("children");
        String governorate = request.getParameter("governorate");
        String hotelName = request.getParameter("hotel_name");
        String price = request.getParameter("price");
        String rating = request.getParameter("rating");
        String stars = request.getParameter("stars");
        String meals = request.getParameter("meals");
        if(checkInDate == null)
        {
            checkInDate = "";
        }
        if(checkOutDate == null)
        {
            checkOutDate = "";
        }
        if(adults == null)
        {
            adults = "";
        }
        if(children == null)
        {
            children = "";
        }
        if(governorate == null)
        {
            governorate = "";
        }
        if(hotelName == null)
        {
            hotelName = "";
        }
        hotels = searchDAO.getAllBy2(checkInDate, checkOutDate, adults, children, governorate, hotelName, price, rating, stars, meals);
        request.setAttribute("hotels", hotels);
        RequestDispatcher rd = request.getRequestDispatcher("views/all_hotels_list.jsp");  
        rd.forward(request, response);
    }
@ Override protected void doGet ( HttpServletRequest request , HttpServletResponse response ) throws ServletException , IOException { HttpSession session = request . getSession ( false ) ; if ( session == null || session . getAttribute ( "user_id" ) == null ) { RequestDispatcher rd = request . getRequestDispatcher ( "views/login.jsp" ) ; rd . forward ( request , response ) ; } List < Hotel > hotels = new ArrayList < Hotel > ( ) ; SearchDAO searchDAO = new SearchDAO ( ) ; String checkInDate = request . getParameter ( "check_in" ) ; String checkOutDate = request . getParameter ( "check_out" ) ; String adults = request . getParameter ( "adults" ) ; String children = request . getParameter ( "children" ) ; String governorate = request . getParameter ( "governorate" ) ; String hotelName = request . getParameter ( "hotel_name" ) ; String price = request . getParameter ( "price" ) ; String rating = request . getParameter ( "rating" ) ; String stars = request . getParameter ( "stars" ) ; String meals = request . getParameter ( "meals" ) ; if ( checkInDate == null ) { checkInDate = "" ; } if ( checkOutDate == null ) { checkOutDate = "" ; } if ( adults == null ) { adults = "" ; } if ( children == null ) { children = "" ; } if ( governorate == null ) { governorate = "" ; } if ( hotelName == null ) { hotelName = "" ; } hotels = searchDAO . getAllBy2 ( checkInDate , checkOutDate , adults , children , governorate , hotelName , price , rating , stars , meals ) ; request . setAttribute ( "hotels" , hotels ) ; RequestDispatcher rd = request . getRequestDispatcher ( "views/all_hotels_list.jsp" ) ; rd . forward ( request , response ) ; }
Handles the HTTP <code>GET</code> method.
Handles the HTTP <code > GET< / code > method .
// optional
