⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customerregistservlet.java

📁 网上购物系统
💻 JAVA
字号:
package com.cric.onlineshopclothes.servlet;

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 com.cric.onlineshopclothes.dao.CustomerRegistDAO;
import com.cric.onlineshopclothes.dao.ManageRegistDAO;
import com.cric.onlineshopclothes.javabean.Customer;

public class CustomerRegistServlet extends HttpServlet {

	
	public CustomerRegistServlet() {
		super();
	}

	
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}

	
	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {


		response.setContentType("text/html;cgarset=utf-8");
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		PrintWriter out = response.getWriter();
		
		
		//get browser data
		CustomerRegistDAO ro=new CustomerRegistDAO();
		Customer customer=ro.registParam(request, response);
		System.out.println(customer.getCustomerName());
		System.out.println(customer.getCustomerPass());
		
		//insert into database
		boolean flag=ro.insertUser(customer);
		if(flag){
			System.out.println("customer insert success!");
		}else{
			System.out.println("customer insert fail!");
		}
		//page redirect
		if(customer.getCustomerName()!=null){
			request.getSession().setAttribute("userName", customer.getCustomerName());
			response.sendRedirect("index.jsp");
		}
   }

	
	public void init() throws ServletException {
		// Put your code here
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -