?? customerregistservlet.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!");
}
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 + -