package web.ParkingSpotRelated;

import pojo.ParkingSpot;
import pojo.User;
import service.ParkingSpotService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

@WebServlet("/main/get_spot")
public class get_spot extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = (HttpSession) request.getSession();
        User user=(User)request.getSession().getAttribute("user");
        ParkingSpotService spot_service=new ParkingSpotService();
        try {
            ParkingSpot spot=  spot_service.getParkingSpot(user.getSpot_id());

            session.setAttribute("spot",spot);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        request.getRequestDispatcher("/main/user/parking_spot.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}


