KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > samples > jpetstore > web > spring > RemoveItemFromCartController


1 package org.springframework.samples.jpetstore.web.spring;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
5
6 import org.springframework.samples.jpetstore.domain.Cart;
7 import org.springframework.web.servlet.ModelAndView;
8 import org.springframework.web.servlet.mvc.Controller;
9 import org.springframework.web.util.WebUtils;
10
11 /**
12  * @author Juergen Hoeller
13  * @since 30.11.2003
14  */

15 public class RemoveItemFromCartController implements Controller {
16
17     public ModelAndView handleRequest(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) throws Exception JavaDoc {
18         Cart cart = (Cart) WebUtils.getOrCreateSessionAttribute(request.getSession(), "sessionCart", Cart.class);
19         cart.removeItemById(request.getParameter("workingItemId"));
20         return new ModelAndView("Cart", "cart", cart);
21     }
22
23 }
24
Popular Tags