日期:2014-05-17 浏览次数:20761 次
response.setContentType("text/html"); PrintWriter out = response.getWriter(); request.setCharacterEncoding("UTF-8"); String uname = request.getParameter("username"); String upwd = request.getParameter("password"); String remember = request.getParameter("remember"); Userinfo u = new Userinfo(); u.setUsermail(uname); u.setPassword(upwd); UserinfoBiz ub = new UserinfoBizImpl(); if (ub.login(u)) { if (remember != null) { uname=new String(uname.getBytes("iso8859-1")); Cookie ckuname = new Cookie("uname", uname); Cookie ckupwd = new Cookie("upwd", upwd); ckuname.setMaxAge(60 * 60 * 24 * 365); ckupwd.setMaxAge(60 * 60 * 24 * 365); response.addCookie(ckuname); response.addCookie(ckupwd); } request.getSession().setAttribute("username", uname); request.getSession().setAttribute("password", upwd); response.sendRedirect("myindex"); } else { response.sendRedirect("login.html"); } out.close();
if (cookie[i].getName().equals("uname")) { unameString = cookie[i].getValue(); unameString=new String(unameString.getBytes("iso8859-1"),"utf-8"); }