hyunjeong

Untitled

Aug 29th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8"%>
  3. <%@ page import= "user.UserDAO" %>
  4. <%@ page import= "java.io.PrintWriter" %>
  5. <% request.setCharacterEncoding("UTF-8"); %>
  6. <jsp:useBean id="user" class="user.User" scope="page" />
  7. <jsp:setProperty name="user" property="userId" />
  8. <jsp:setProperty name="user" property="userPassword" />
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  12. <title>jsp 게시판 웹사이트</title>
  13. </head>
  14. <body>
  15. <%
  16. if(user.getUserId() ==null || user.getUserPassword() == null) {
  17. PrintWriter script = response.getWriter();
  18. script.println("<script>");
  19. script.println("alert('입력되지 않은 사항이 있습니다.')");
  20. script.println("history.back()");
  21. script.println("</script>");
  22. }
  23. String userId = null;
  24.  
  25. if(session.getAttribute("userId") != null) {
  26. userId = (String) session.getAttribute("userId");
  27. }
  28.  
  29. UserDAO userDAO = new UserDAO();
  30. int result = userDAO.login(user.getUserId(), user.getUserPassword());
  31. if(result==1) {
  32. session.setAttribute("userId", user.getUserId());
  33. PrintWriter script = response.getWriter();
  34. script.println("<script>");
  35. script.println("alert('로그인 되었습니다. ')");
  36. script.println("location.href= 'main.jsp' ");
  37. script.println("</script>");
  38. } else if (result==0){
  39. PrintWriter script = response.getWriter();
  40. script.println("<script>");
  41. script.println("alert('비밀번호가 틀립니다.')");
  42. script.println("history.back()");
  43. script.println("</script>");
  44. } else if (result == -1) {
  45. PrintWriter script = response.getWriter();
  46. script.println("<script>");
  47. script.println("alert('존재하지 않는 아이디입니다.')");
  48. script.println("history.back()");
  49. script.println("</script>");
  50. } else if (result == -2 ) {
  51. PrintWriter script = response.getWriter();
  52. script.println("<script>");
  53. script.println("alert('데이터베이스 오류가 발생했습니다.')");
  54. script.println("history.back()");
  55. script.println("</script>");
  56. }
  57. %>
  58.  
  59.  
  60.  
  61.  
  62.  
  63. </body>
  64. </html>
Add Comment
Please, Sign In to add comment