내 블로그 목록

2018년 7월 17일 화요일

[JSP] JDBC,커넥션 풀을 이용한 로그인/회원가입/마이페이지/모든회원정보 보기





1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
1.indexHome.jsp ----------------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page session = "true" %>
<%  request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="member" scope="session" class="Table.member"/>
<jsp:include page="index.jsp" flush="false" />
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style>
        body{
            margin: 0px;
            background: #f5f6f7;
        }
        
        #main{
           width: 1000px;
           margin: 0 auto;
        }
        
    </style>
</head>
<body>
   
    <div id="main">
      <img src="img/cat.jpg" width="1000px;"/>
    </div>
    
</body>
</html>
<jsp:include page="footer.jsp" flush="false" />
    
3. index.jsp ----------------------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page session = "true" %>
<%  request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="member" scope="session" class="Table.member"/>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style>
        body{
            margin: 0px;
        }
        
        #topnav{
            background: #08a600;
            width:100%;
            height: 51px;
        }
        
        #topnav a{
            float: left;
            background: #08a600;
            color: #fff;
            text-align: center;
            padding: 14px 16px;
            text-decoration: none;
            font-size: 17px;
            
            cursor:pointer;
        }
        
        #topnav a:hover{
            opacity: 0.8;
        }
        
        #topnav a:active{
            background: white;
            color: #08a600;
        }
    </style>
</head>
<body>
    <div id="topnav">
        <a href="indexHome.jsp"></a>
      <%if(member.getId()!=null && member.getPwd()!=null){ %>
        <a href="MyPageForm.jsp">MyPage</a>
        <a href="MemberAllPage.jsp">MemberList</a>
        <a href="logoutAct.jsp">로그아웃</a>
        
        
      <%}else{%>
        <a href="RegisterFirst.jsp">회원가입</a>
        <a href="loginForm.jsp">로그인</a>
        
     <%}%>
    </div>
</body>
</html>
3. footer.jsp ---------------------------------------------------------------------------------------
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%  request.setCharacterEncoding("UTF-8"); %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>footer</title>
<style> 
        body{
            margin: 0px;
        }
        
       #footer {
            margin: 0px;
            margin-bottom:10px;
            padding: 0px;
            text-align: center;
        }
        #footer ul {
            padding: 0px;
            margin-top: 30px;
            margin-bottom: 9px;
        }
        #footer ul li {
            list-style: none;
            display: inline;
        }
        #footer ul li a {
            text-decoration: none;
            padding: 0 4px;
            border-right: 1px solid #ccc;
            font-size: 12px;
            color: #333;
        }
        #footer img {
            width: 63px;
            margin-bottom: -4px;
        }
        #footer label {
            font-size: 10px;
            color: #333;
        }
</style>
</head>
<body>
    <div id="footer">
            <ul>
                <li><a href="#">이용약관 </a></li>
                <li><a href="#">개인정보처리방침 </a></li>
                <li><a href="#">책임의 한계와 법적고지 </a></li>
                <li><a href="#">회원정보 고객센터</a></li>
            </ul>
            <img src="img/footernaver.JPG">
            <label>Copyright <b>Naver Crop.</b> All Rights Reserved.</label>
     </div>
</body>
</html>
cs



회원가입



약관 비동의 시, 홈으로 / 약관 동의 시, 회원가입 폼으로.



[RegisterSecond.jsp]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="RegisterSecond.css">
<head>
    <title>네이버 : 회원가입</title>
    <style>
    </style>
</head>
<body>
    <div id="naver">
        <div id="header">
            <img src="img/naver.JPG">
        </div>
        <div id="container">
        
            <form action="RegisterAct.jsp">
                <label for="id">아이디</label>
                <div id="idBox" class="box">
                    <input type="text" id="id" name="id" class="input">
                    <span>@naver.com</span>
                </div>
                <p id="redCheck_id" class="redCheck"></p>
                <label for="pwd">비밀번호</label>
                <div id="pwdBox" class="box">
                    <input type="password" id="pwd" name="pwd" class="input">
                    <img src="https://static.nid.naver.com/images/ui/join/pc_icon_pass_180417.png">
                </div>
                <p id="redCheck_pwd" class="redCheck"></p>
                <label for="pwdCheck">비밀번호 재확인</label>
                <div id="pwdCheckBox" class="box">
                    <input type="password" id="pwdCheck" class="input">
                    <img src="https://static.nid.naver.com/images/ui/join/pc_icon_check_disable_180417.png">
                </div>
                <p id="redCheck_pwdCheck" class="redCheck"></p>
                <label for="name">이름</label>
                <div id="nameBox" class="box">
                    <input type="text" id="name" name="name" class="input">
                </div>
                <p id="redCheck_name" class="redCheck"></p>
                <label>생년월일</label>
                <div id="birth">
                    <input type="number" name="birth_year" placeholder="년(4자)">
                    <select name="birth_mon">
                    <option></option>
                    <option>01</option>
                    <option>02</option>
                    <option>03</option>
                    <option>04</option>
                    <option>05</option>
                    <option>06</option>
                    <option>07</option>
                    <option>08</option>
                    <option>09</option>
                    <option>10</option>
                    <option>11</option>
                    <option>12</option>
                    
                     </select>
                    <input type="number" name="birth_day" placeholder="일">
                </div>
                <p id="redCheck_birth" class="redCheck"></p>
                <label>성별</label>
                  <div class="gender-box box1 ">
                <div>
                    <input type="radio" id="man" name="gender" value="M">
                    <label for="man">남자</label>
                </div>
                <div>
                    <input type="radio" id="woman" name="gender" value="F">
                    <label for="woman">여자</label>
                </div>
            </div>
            
                <label for="email">본인 확인 이메일</label>
                <div id="email" class="box">
                    <input type="text" name="email" placeholder="선택입력"  class="input">
                </div>
                <p id="redCheck_email" class="redCheck"></p>
                <label for="phone">휴대전화</label>
                <select id="phoneSel" >
                <option value="+82">대한민국 +82</option>
                <option value="+64">네덜란드 +64</option>
                <option value="+47">노르웨이 +47</option>
                <option value="+227">니제르 +227</option>
            </select>
                <input type="button" id="phoneBtn" value="인증번호 받기">
                <div id="phoneBox" class="box">
                    <input type="text" id="phone" name="phone" class="input" placeholder="전화번호 입력">
                </div>
                <div id="serialBox" class="box">
                    <input type="text" id="serialPhone" class="input" placeholder="인증번호 입력하세요">
                </div>
                 <p id="redCheck_phone" class="redCheck"></p>
                <input type="submit" id="send" value="가입하기">
            </form>
        </div>
        <div id="footer">
            <ul>
                <li><a href="#">이용약관 </a></li>
                <li><a href="#">개인정보처리방침 </a></li>
                <li><a href="#">책임의 한계와 법적고지 </a></li>
                <li><a href="#">회원정보 고객센터</a></li>
            </ul>
            <img src="img/footernaver.JPG">
            <label>Copyright <b>Naver Crop.</b> All Rights Reserved.</label>
        </div>
    </div>
</body>
</html>
cs



[RegisterAct.jsp]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
<%@page import="java.sql.Date"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" class="Table.member"/>
<jsp:setProperty name="member" property="*"/>
<jsp:include page="index.jsp" flush="false" />
<%
 Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
try{
    String jdbcDriver = "jdbc:apache:commons:dbcp:pooltest";
    conn = DriverManager.getConnection(jdbcDriver);
    
    String sql_insert = "insert into member values(?,?,?,?,?,?,?)";
    
    pstmt = conn.prepareStatement(sql_insert);
    pstmt.setString(1, member.getId());
    pstmt.setString(2, member.getPwd());
    pstmt.setString(3, member.getName());    
    
    String birth = member.getBirth_year()+"-"+member.getBirth_mon() +"-"+member.getBirth_day();
    pstmt.setString(4, birth);
    pstmt.setString(5, member.getGender());
    pstmt.setString(6, member.getEmail());
    pstmt.setInt(7, member.getPhone());
    
    pstmt.executeQuery();
    System.out.println("회원가입 데이터 삽입 완료!");
  
    pstmt.close();
}catch(SQLException e){
    out.println(e.getMessage());
    e.printStackTrace();
}finally{
    if(stmt!=nulltry{stmt.close();}catch(SQLException e){}
    if(conn!=nulltry{conn.close();}catch(SQLException e){}
}
%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="MyPageForm.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>회원가입 확인</title>
<style>
</style>
</head>
<body>
<div id="containAll">
    <div id="container">
        <h1 style="font-size:50px;">회원정보 확인</h1>
        <p>회원가입을 축하드립니다!</p>
        <table>
            <tr>
                <td>ID</td>  
                <td>${member.id}</td>
            </tr>
            
            <tr>
                <td>비밀번호</td>
                <td>${member.pwd}</td>
            </tr>
            
            <tr>
                <td>이름</td>
                <td>${member.name}</td>
            </tr>
         
            <tr>
                <td>생일</td>
                <td>${member.birth_year}/${member.birth_mon}/${member.birth_day}</td>
            </tr>
            
            <tr>
                <td>성별</td>
                <td>${member.gender}</td>
            </tr>
            
            <tr>
                <td>이메일</td>
                <td>${member.email}</td>
            </tr>
            
            <tr>
                <td>핸드폰 번호</td>
                <td>${member.phone}</td>
            </tr>
            
             <tr>
                <td colspan="2" style="text-align: center;"><input type="button" value="로그인" onclick="location.href='loginForm.jsp'"></td>
            </tr>
         </table>
    </div>
</div>
</body>
</html>
<jsp:include page="footer.jsp" flush="false" />
cs

회원가입이 완료되면 자동으로 로그인 페이지로 넘어간다.

코드가 긴 관계로 (0)약관동의 부분의 코드와 (1)RegisterSecond.jsp의 js부분, (2)RegisterSecond.css파일은 생략했다.

이는 첨부파일로 붙인다.




로그인

[loginForm.jsp]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<%@page import="javax.crypto.Cipher"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="index.jsp" flush="false" />
<!DOCTYPE html>
<html>
<link rel="stylesheet" type="text/css" href="loginForm.css">
<head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
     <title>로그인</title>
</head>
<%
  request.setCharacterEncoding("UTF-8");
  String id = "";
  Cookie[] c = request.getCookies();
  
  if(c!=null && c.length>0){
      for(int i=0; i<c.length; i++){
          if(c[i].getName().equals("id"))
              id=c[i].getValue();
      }
  }
%>
<body>
    <div id="containAll">
        <div id="header">
            <select>
                <option selected="">한국어</option>
                <option>English</option>
                <option>中文(简体)</option>
                <option>中文(台灣)</option>
            </select>
            <img src="img/naver.JPG">
        </div>
        
        <div id="container">
            <form action="loginAct.jsp">
             <div class="box">
              <input type="text" id="id" name="id" class="input" placeholder="아이디" value=<%=id%>>
             </div>
             <div class="box">
              <input type="password" id="password" name="pwd" class="input" placeholder="비밀번호">
             </div>
                
              <input type="submit" value="로그인">
              <input type="checkbox" id="remember" name="remember" value="remember"
              <label for="remember">아이디 저장</label>
            </form>
        </div>
    </div>
</body>
</html>
<jsp:include page="footer.jsp" flush="false" />
cs


[loginAct.jsp]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Date"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" scope="session" class="Table.member"/>
<jsp:setProperty name="member" property="*"/>
<%
 String id = request.getParameter("id");
 String pwd = request.getParameter("pwd");
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String password;
try{
    String jdbcDriver = "jdbc:apache:commons:dbcp:pooltest";
    conn = DriverManager.getConnection(jdbcDriver);
    
    String sql_select = "select * from member where id='"+ id+"'";
    stmt = conn.createStatement();    
    rs = stmt.executeQuery(sql_select);  
    
/*     String sql ="select * from member where Id = ?"; 
    
    pstmt = conn.prepareStatement(sql);
    pstmt.setString(1, id);
    
    rs = pstmt.executeQuery();  */
    
    if(rs.next()){
        password = rs.getString("PWD");
    
        if(password!=null){
            if(password.equals(pwd)){
                
                session.setAttribute("id", id);
                session.setAttribute("pwd", pwd);
                
                out.println("<script>");
                out.println("alert('환영합니다!')");
                out.println("location.href='indexHome.jsp'");
                out.println("</script>");
                
            }else{
                out.println("<script>");
                out.println("alert('비밀번호가 틀렸습니다.')");
                out.println("location.href='loginForm.jsp'");
                out.println("</script>");
            }
        }
        
    }else{
        out.println("<script>");
        out.println("alert('아이디가 틀렸습니다.')");
        out.println("location.href='loginForm.jsp'");
        out.println("</script>");
    }
    
    
}catch(SQLException e){
    out.println(e.getMessage());
    e.printStackTrace();
}finally{
    if(rs!=nulltry{rs.close();}catch(SQLException e){}
    if(stmt!=nulltry{stmt.close();}catch(SQLException e){}
    if(conn!=nulltry{conn.close();}catch(SQLException e){}
}
%>
  
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
</style>
</head>
<body>
</body>
</html>
cs


로그인이 완료되면 자동으로 홈으로 넘어간다.
로그인 완료 시, 메뉴가 달라진다. 이 부분은 세션과 빈즈로 처리했다.



마이페이지


[MyPageForm.jsp]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<jsp:useBean id="member" scope="session" class="Table.member"/>
<jsp:include page="index.jsp" flush="false" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="MyPageForm.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>마이페이지</title>
<style>
</style>
</head>
<body>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
    String jdbcDriver = "jdbc:apache:commons:dbcp:pooltest";
    conn = DriverManager.getConnection(jdbcDriver);
    
     String sql_select = "select * from member where id='"+ member.getId() +"'"
     
     stmt = conn.createStatement();
     rs = stmt.executeQuery(sql_select);
    
     if(rs.next()){
 %>
 <div id="containAll">
     <div id="container">
           <h1>My Page </h1>
          <table>
       <tr>
          <td>아이디</td>
          <td><%= rs.getString("ID"%></td>
       </tr>   
       
       <tr>
          <td>비밀번호</td>
          <td><%= rs.getString("PWD"%></td>
       </tr>   
       
        <tr>
          <td>이름</td>
          <td><%= rs.getString("NAME"%></td>
       </tr>   
       
        <tr>
          <td>생년월일</td>
          <td><%= rs.getDate("BIRTH"%></td>
       </tr>   
       
        <tr>
          <td>성별</td>
          <td><%= rs.getString("GENDER"%></td>
       </tr>   
      
       <tr>
          <td>이메일</td>
          <td><%= rs.getString("EMAIL"%></td>
       </tr>   
       
        <tr>
          <td>핸드폰 번호</td>
          <td><%= rs.getString("PHONE"%></td>
       </tr>   
       
       <tr>
          <td colspan="2"><input type="button" value="홈으로 가기" onclick="location.href='indexHome.jsp'"/></td>
       </tr>   
       </table>
       </div>
       </div>
     
<%    }else{
    out.println("<script>");
    out.println("alert('로그인 해주세요.')");
    out.println("location.href='loginForm.jsp'");
    out.println("</script>");
   }
     
}catch(SQLException e){
    out.println(e.getMessage());
    e.printStackTrace();
}finally{
    if(stmt!=nulltry{stmt.close();}catch(SQLException e){}
    if(conn!=nulltry{conn.close();}catch(SQLException e){}
}
%>
</body>
</html>
<jsp:include page="footer.jsp" flush="false" />
cs




모든 회원 정보 보기


[MemberAllPage.jsp]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.PreparedStatement"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:include page="index.jsp" flush="false" />
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="MemberAllPage.css">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MemberList Page</title>
<style>
</style>
</head>
<body>
<%
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try{
    String jdbcDriver = "jdbc:apache:commons:dbcp:pooltest";
    conn = DriverManager.getConnection(jdbcDriver);
    
     String sql_select = "select * from member"
     
     stmt = conn.createStatement();
     rs = stmt.executeQuery(sql_select);
    
 %>
 <div id="containAll">
    <div id="container">
    <h1>모든 회원정보 보기</h1>
    
    <table>
       <tr>
          <th>아이디</th>
          <th>비밀번호</th>
          <th>이름</th>
          <th>생년월일</th>
          <th>성별</th>
          <th>이메일</th>
          <th>핸드폰 번호</th>
       </tr>   
       
<%    while(rs.next()){ %>
       <tr>
          <td><%= rs.getString("ID"%></td>
          <td><%= rs.getString("PWD"%></td>
          <td><%= rs.getString("NAME"%></td>
          <td><%= rs.getDate("BIRTH"%></td>
          <td><%= rs.getString("GENDER"%></td>
          <td><%= rs.getString("EMAIL"%></td>
          <td><%= rs.getString("PHONE"%></td>
       </tr>   
  <%%>
       <tr>
       <td colspan="7"><input type="button" value="홈으로 가기"  onclick="location.href='indexHome.jsp'"/></td>
       </tr>
      
             </table>
       </div>
       </div>
     
<%
}catch(SQLException e){
    out.println(e.getMessage());
    e.printStackTrace();
}finally{
    if(stmt!=nulltry{stmt.close();}catch(SQLException e){}
    if(conn!=nulltry{conn.close();}catch(SQLException e){}
}
%>
</body>
</html>
<jsp:include page="footer.jsp" flush="false" />
cs




로그아웃



[logoutAct.jsp]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>로그인</title>
<style>
</style>
</head>
<body>
<%  
   session.invalidate();
    out.println("<script>");
    out.println("alert('로그아웃 되었습니다.')");
    out.println("location.href='loginForm.jsp'");
    out.println("</script>");
    
   /* response.sendRedirect("indexHome.jsp"); */
%>
</body>
</html>
cs

로그아웃을 하면, ‘로그아웃 되었습니다’라는 알람이 뜨고, 다음 그림과 같이 홈으로 간다.



모든 css 파일은 첨부 파일로 첨부한다.

읽어주셔서 감사합니다.


댓글 2개:

  1. 이번엔 셀프 인터뷰 없나요 :(

    답글삭제
    답글
    1. '이전 게시물' 클릭하시면 '[JSP]일간 뷰어 인터뷰_커넥션 풀편'있습니다~~^^

      삭제