Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page language="java" contentType="text/html; charset=UTF-8"
- pageEncoding="UTF-8"%>
- <%@ page import= "user.UserDAO" %>
- <%@ page import= "java.io.PrintWriter" %>
- <% request.setCharacterEncoding("UTF-8"); %>
- <jsp:useBean id="user" class="user.User" scope="page" />
- <jsp:setProperty name="user" property="userId" />
- <jsp:setProperty name="user" property="userPassword" />
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>jsp 게시판 웹사이트</title>
- </head>
- <body>
- <%
- if(user.getUserId() ==null || user.getUserPassword() == null) {
- PrintWriter script = response.getWriter();
- script.println("<script>");
- script.println("alert('입력되지 않은 사항이 있습니다.')");
- script.println("history.back()");
- script.println("</script>");
- }
- String userId = null;
- if(session.getAttribute("userId") != null) {
- userId = (String) session.getAttribute("userId");
- }
- UserDAO userDAO = new UserDAO();
- int result = userDAO.login(user.getUserId(), user.getUserPassword());
- if(result==1) {
- session.setAttribute("userId", user.getUserId());
- PrintWriter script = response.getWriter();
- script.println("<script>");
- script.println("alert('로그인 되었습니다. ')");
- script.println("location.href= 'main.jsp' ");
- script.println("</script>");
- } else if (result==0){
- PrintWriter script = response.getWriter();
- script.println("<script>");
- script.println("alert('비밀번호가 틀립니다.')");
- script.println("history.back()");
- script.println("</script>");
- } else if (result == -1) {
- PrintWriter script = response.getWriter();
- script.println("<script>");
- script.println("alert('존재하지 않는 아이디입니다.')");
- script.println("history.back()");
- script.println("</script>");
- } else if (result == -2 ) {
- PrintWriter script = response.getWriter();
- script.println("<script>");
- script.println("alert('데이터베이스 오류가 발생했습니다.')");
- script.println("history.back()");
- script.println("</script>");
- }
- %>
- </body>
- </html>
Add Comment
Please, Sign In to add comment