-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample10.jsp
48 lines (43 loc) · 1.1 KB
/
example10.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
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Input</title>
</head>
<body>
<%if(request.getMethod().equals("POST")) {%>
<%
String id = request.getParameter("id");
String pwd = request.getParameter("pwd");
// 유효성 체크
if(id.isEmpty() || pwd.isEmpty())
{
request.setAttribute("error", "ID 또는 비밀번호를 입력해주세요!");
RequestDispatcher rd = request.getRequestDispatcher("logInOut.jsp");
rd.forward(request,response);
return;
}
//로그인 처리
if(session.isNew() || session.getAttribute("id") == null )
{
session.setAttribute("id", id);
out.print("로그인 작업이 완료되었습니다.");
}else{
out.print("이미 로그인 상태입니다.");
}
%>
<%= id %> / <%= pwd %>
<%}else if(request.getMethod().equals("GET")) {
if(session!=null && session.getAttribute("id")!=null)
{
session.invalidate();
out.print("로그아웃 작업이 완료되었습니다.");
}else{
out.print("현재 로그인 상태가 아닙니다.");
}
}
%>
</body>
</html>