www.pudn.com > bookshop.zip > DeleteServlet.java, change:2013-07-09,size:895b


package com.tarena.web; 
 
import java.io.IOException; 
import java.io.PrintWriter; 
 
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.Cart; 
 
public class DeleteServlet 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"); 
        HttpSession session = request.getSession(); 
        Cart cart =(Cart)session.getAttribute("cart"); 
         
        cart.delete(Integer.parseInt(id)); 
        response.sendRedirect("Cart"); 
         
	} 
 
}