국비필기노트/jsp
jsp_로그아웃
개발..너...
2022. 6. 13. 13:59
*로그아웃 버튼 생성
1
|
<input type="button" value="로그아웃" onclick="location.href='logout_db.jsp'">
|
cs |
*로그아웃 db 파일 생성
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
session.removeAttribute("session_id");
response.sendRedirect("login_view.jsp");
%>
</body>
</html>
|
cs |
로그아웃 버튼을 누름으로서 세션에 저장된 아이디를 제거해주고 다시 로그인 페이지로 이동시켜주는 코드이다.
- session.removeAttribute("session_id")로 세션의 아이디를 삭제한다.
- response.sendRedirect(" " ); 로그인 페이지로 이동시킨다.