¼ÛÁ¤¿ì °»ç ´ÔÀÌ ¾²½Å ¿ø¹® ±ÛÀÔ´Ï´Ù.
º¸´Ï±î ¼ºí¸´¿¡¼ °´Ã¼¸¦ »ý¼ºÇÏÁö ¾Ê°í ÇϳªÀÇ °´Ã¼¿¡ µ¥ÀÌÅÍ°¡ °è¼Ó ´ã±â´Â °Í °°½À´Ï´Ù.
¼ºí¸´ ÆÄÀÏÀ» º¸³»ÁÖÁö ¾ÊÀ¸¼Å¼ È®ÀÎÀº µÇÁö ¾ÊÁö¸¸ ¾Æ·¡ ¼Ò½º¸¦ Âü°íÇϼż È®ÀÎÇØ º¸½Ã±â ¹Ù¶ø´Ï´Ù.
-----------------------------------------------
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.setCharacterEncoding("euc-kr");
String param = req.getParameter("param");
String url = "";
HttpSession session = req.getSession();
Vector bookList =
(Vector)session.getAttribute("bookList");
if(param.equals("CHK")){
url = "/WEB-INF/exam2/checkout.jsp";
int sum = 0;
for(int i=0; i if(param.equals("CART")){
if(bookList == null){
bookList = new Vector();
}
bookList.add(getBook(req));
}
else if(param.equals("DEL")){
int idx = Integer.parseInt(req.getParameter("idx"));
bookList.remove(idx);
}
}
session.setAttribute("bookList", bookList);
RequestDispatcher view =
req.getRequestDispatcher(url);
view.forward(req, resp);
}
public BookDto getBook(HttpServletRequest req){
String book = req.getParameter("book");
String qty = req.getParameter("quantity").trim();
StringTokenizer token = new StringTokenizer(book, "/");
String title = token.nextToken().trim();
String author = token.nextToken().trim();
String price = token.nextToken().trim();
BookDto dto = new BookDto();
dto.setAuthor(author);
dto.setPrice(Integer.parseInt(price));
dto.setQuantity(Integer.parseInt(qty));
dto.setTitle(title);
return dto;
}