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


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; 
import com.tarena.bean.ReceiveAddress; 
import com.tarena.bean.User; 
import com.tarena.dao.ReceiveAddDao; 
 
public class RecAddServlet extends HttpServlet { 
 
	public void service(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException { 
		 
		 request.setCharacterEncoding("utf-8"); 
         response.setContentType("text/html;charset=utf-8"); 
          
          
         HttpSession session = request.getSession(); 
         User user=(User)session.getAttribute("user"); 
         int user_id = user.getId(); 
 
          
         String receive_name = request.getParameter("receiveName"); 
         String full_address = request.getParameter("fullAddress"); 
         String postal_code = request.getParameter("postalCode"); 
         String phone = request.getParameter("phone"); 
         String mobile = request.getParameter("mobile"); 
         //System.out.println(receive_name); 
          
         String total_price =Double.toString(((Cart)session.getAttribute("cart")).getpricetotal()); 
         //Date date =  
         //String order_time =request.getParameter("odok"); 
        // System.out.println(order_time); 
         ReceiveAddress ra = new ReceiveAddress(); 
         ra.setUser_id(user_id); 
         ra.setReceive_name(receive_name); 
         ra.setFull_address(full_address); 
         ra.setPostal_code(postal_code); 
         ra.setPhone(phone); 
         ra.setMobile(mobile); 
          
         ra.setTotal_price(Double.valueOf(total_price)); 
          
          
         ReceiveAddDao raDao = new ReceiveAddDao(); 
         raDao.ReceiveAdd(ra); 
         raDao.Dingdan(ra); 
         response.sendRedirect("order_ok.jsp"); 
 
	} 
 
}