www.pudn.com > bookshop.zip > UpdateCart.java, change:2013-07-10,size:982b


package com.tarena.web; 
 
import java.io.IOException; 
import java.io.PrintWriter; 
import java.util.Map; 
 
import javax.servlet.ServletException; 
import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 
import javax.servlet.http.HttpSession; 
 
import com.tarena.bean.Book; 
import com.tarena.bean.Cart; 
 
public class UpdateCart extends HttpServlet { 
 
	public void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException { 
		 
		request.setCharacterEncoding("utf-8"); 
        response.setContentType("text/html;charset=utf-8"); 
         
        String id = request.getParameter("id"); 
        String num = request.getParameter("num"); 
        HttpSession session=request.getSession();  
		Cart cart=(Cart)session.getAttribute("cart"); 
		cart.update(Integer.parseInt(id),Integer.parseInt(num)); 
		response.sendRedirect("Cart"); 
	} 
 
}