protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
try (PrintWriter out = response.getWriter()) {
UserbeanCL ubcl = new UserbeanCL();
String jizhu = request.getParameter("ck");
String myUser = request.getParameter("userName");
String myPassword = request.getParameter("password");
if (ubcl.denglu(myUser, myPassword)) {
request.getSession().setAttribute("mima", myPassword);
if ("on".equals(jizhu)) {
Cookie myck = new Cookie("mycookie", myUser + "#" + myPassword);
myck.setMaxAge(24 * 60 * 60 * 7);
response.addCookie(myck);
}
response.sendRedirect("goods.jsp");
} else {
out.println("<html><script>alert('不存在这个用户,请重新输入!');setTimeout(function(){window.location.href='index.jsp';},1);</script></html>");
}
}
}