본문 바로가기

국비필기노트/jsp

jsp_로그아웃

*로그아웃 버튼 생성

 

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(" " ); 로그인 페이지로 이동시킨다.

'국비필기노트 > jsp' 카테고리의 다른 글

jsp_아이디중복체크  (0) 2022.06.14
jsp_Ajax  (0) 2022.06.13
jsp_자바빈즈태그  (0) 2022.06.08
jsp_DB에서 여러 데이터 가져오기  (0) 2022.06.08
jsp_DB 연결(DB계정생성, Java-DB연결)  (0) 2022.06.03