login.jsp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <!DOCTYPE html>
  4. <html>
  5. <head>
  6. <meta charset="UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. <% String msg=(String)request.getAttribute("msg");
  11. Cookie[] cookies = request.getCookies();
  12. String cUser = "";
  13. String cPassword = "";
  14. if (cookies != null) {
  15. int x = cookies.length;
  16. for (int i = 0; i < x; i++) {
  17. Cookie cookie = cookies[i];
  18. if ("username".equals(cookie.getName())) {
  19. cUser = cookie.getValue();
  20. }
  21. if ("password".equals(cookie.getName())) {
  22. cPassword = cookie.getValue();
  23. }
  24. }
  25. }
  26. %>
  27. <font color="red"><%=msg==null?"":msg %></font>
  28. <form action="login_test.jsp" method="post">
  29. username:<input type="text" name="username" value="<%=cUser%>">
  30. <p>
  31. password:<input type="password" name="password"
  32. value="<%=cPassword%>">
  33. <p>
  34. 记住密码: <input type="checkbox" value="1" name="flag">
  35. <p>
  36. <a href="Register.jsp">注册</a>
  37. <p>
  38. <input type="submit" value="登录">
  39. <input type="reset" value="清空">
  40. </form>
  41. </body>
  42. </html>