protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    HttpSession session = request.getSession();
    int bookId = 0;
    Books book = null;
    BookService bs = BookService.getInstance();
    if (session.getAttribute("admin") == null) {
      response.sendRedirect("error");
      return;
    } else {
      try {
        bookId = Integer.parseInt(request.getParameter("bookId"));
        book = bs.getbooks(bookId, null, null, null, null, null).get(0);
      } catch (Exception e) {
        String path = request.getContextPath();
        response.sendRedirect(path + "/error");
        e.printStackTrace();
        return;
      }

      request.setAttribute("book", book);
      RequestDispatcher dispatcher = request.getRequestDispatcher("edit_book.jsp");
      dispatcher.forward(request, response);
      return;
    }
  }
 protected void doPost(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   Map<String, String[]> map = request.getParameterMap();
   int bookId = Integer.parseInt(request.getParameter("id"));
   BookService abs = BookService.getInstance();
   abs.editBook(map, bookId);
   response.sendRedirect("book_detail/" + bookId);
   return;
 }