@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        String action = request.getParameter("action");
        if (Utils.isNullOrEmpty(action)) {
            return;
        }
        PrintWriter out = response.getWriter();
        if (action.equals("getall")) {
            List<ReservationDAO.Reservation> reservations = ReservationDAO.getAllReservations();
            String json = Utils.toJSON(reservations);
            out.write(json);
        } else if (action.equals("reserve")) {
            //somebody clicked to make a reservation - only process if user            
            HttpSession session = request.getSession();
            UserDAO.User currentuser = (UserDAO.User) session.getAttribute("user");
            if (currentuser.usertype != UserDAO.USER) {
                out.write("denied");
            } else {
                int userid = currentuser.id;
                int eventid = ((EventDAO.Event) session.getAttribute("event")).id;
                java.util.Date date = new java.util.Date();
                Timestamp timereserved = new Timestamp(date.getTime());
                int slotnum = Integer.parseInt(request.getParameter("slotnum"));
                //calculate the time of the slot
                EventDAO.Event event = (EventDAO.Event) session.getAttribute("event");
                Timestamp eventstart = event.startTime;
                long starttime = eventstart.getTime() + TimeUnit.MINUTES.toMillis(event.duration * slotnum);
                Timestamp s_time = new Timestamp(starttime);

                ReservationDAO.Reservation res = ReservationDAO.createReservation(userid, eventid, timereserved, s_time, slotnum);
                //format the time for easy display
                SimpleDateFormat formatter = new SimpleDateFormat("h:mm a");
                res.stime = formatter.format(s_time);
                if (res != null) {
                    //out.write("success");
                    out.write(Utils.toJSON(res));
                } else {
                    out.write("fail");
                }
            }
        }
        out.flush();
        out.close();
    }