hyunjeong

Untitled

Aug 29th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 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. <jsp:setProperty name="user" property="userName" />
  10. <jsp:setProperty name="user" property="userGender" />
  11. <jsp:setProperty name="user" property="userEmail" />
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  15. <title>jsp 게시판 웹사이트</title>
  16. </head>
  17. <body>
  18. <%
  19.  
  20. String userId = null;
  21.  
  22. if(session.getAttribute("userId") != null) {
  23. userId = (String) session.getAttribute("userId");
  24. }
  25.  
  26. if (userId != null ) {
  27. PrintWriter script = response.getWriter();
  28. script.println("<script>");
  29. script.println("alert('이미 로그인이 되어 있습니다. ')");
  30. script.println("location.href= main.jsp");
  31. script.println("</script>");
  32.  
  33. }
  34.  
  35. if (user.getUserId()==null || user.getUserPassword()==null || user.getUserName() ==null ||
  36. user.getUserGender()==null || user.getUserEmail()==null) {
  37. PrintWriter script = response.getWriter();
  38. script.println("<script>");
  39. script.println("alert('입력이 안 된 사항이 있습니다.')");
  40. script.println("history.back()");
  41. script.println("</script>");
  42. } else {
  43.  
  44.  
  45. UserDAO userDAO = new UserDAO();
  46. int result = userDAO.join(user);
  47.  
  48. if(result== - 1) {
  49. PrintWriter script = response.getWriter();
  50. script.println("<script>");
  51. script.println("alert('이미 존재하는 아이디입니다.')");
  52. script.println("history.back()");
  53. script.println("</script>");
  54. } else {
  55. PrintWriter script = response.getWriter();
  56. script.println("<script>");
  57. script.println("alert('비밀번호가 틀립니다.')");
  58. script.println("history.back()");
  59. script.println("</script>");
  60. }
  61. }
  62. %>
  63.  
  64.  
  65.  
  66.  
  67.  
  68. </body>
  69. </html>
Add Comment
Please, Sign In to add comment