반응형
footer.jsp
<%@ 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>
<footer class="container">
<p>© WebMarket</p>
</footer>
</body>
</html>
welcome.jsp
<%@page import="java.util.Scanner"%>
<%@page import ="java.text.SimpleDateFormat"%>
<%@page import = "java.util.Date"%>
<%
Date today = new Date();
SimpleDateFormat format1 = new SimpleDateFormat("E M dd HH:mm:ss z yyyy");
%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
<meta charset="UTF-8">
<title>JSP</title>
</head>
<body>
<%@ include file="menu.jsp" %>
<div class="container-fluid bg-secondary bg-opacity-25">
<div class="p-5 mb-5">
<h1 class="display-h1">웹 쇼핑몰에 오신 것을 환영합니다</h1>
</div>
</div>
<main role = "main">
<div class ="container">
<div class ="text-center">
<h3>
Welcome to Web Market!
</h3>
현재 시간:
<%= format1.format(today) %>
</div>
</div>
</main>
</div>
<%@ include file="footer.jsp" %>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js">
</script>
</body>
</html>
menu.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="container-fluid">
<a class="navbar-brand" a href="welcome.jsp">Home</a>
<%@ include file="loginbutton.jsp" %>
</div>
</nav>
</body>
</html>
loginbutton.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String uid = (String)session.getAttribute("id");
%>
<%
if (uid == null) {
%>
<div>
<a class="btn btn-secondary btn-lg" href="login2.html" role="button">Login</a>
</div>
<%
} else if (uid != null) {
%>
<div>
<a class="btn btn-secondary btn-lg" href="logout.jsp" role="button">Logout</a>
</div>
<%};
%>
login.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="utf-8"%>
<%
String uid = request.getParameter("id");
String ups = request.getParameter("ps");
if ( uid == null ){
out.println("로그인 정보가 없습니다.");
}
else {
session.setAttribute("id", uid);
session.setAttribute("ps", ups);
session.setMaxInactiveInterval(5);
response.sendRedirect("welcome.jsp");
}
%>
login2.html
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="login.jsp" method="post">
</div>
<table align=center>
<tr><td colspan=2 align=center height=40><b><h1 class="display-1">Login</h1></b><td></tr>
<tr>
<td align=right>아이디 </td>
<td><input type="text" name="id" placeholder="Email address" required></td>
</tr>
<td align=right>패스워드 </td>
<td><input type="password" name="ps" required></td>
</tr>
<td colspan=2 align=center height=50>
<input type="submit" value="Login">
</td>
</tr>
</table>
</form>
</body>
</html>
login2.html 화면
logout.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%
session.invalidate();
response.sendRedirect("welcome.jsp");
%>
로그인 성공 화면
궁금한 점이 있으시면 댓글 달아주세요. 감사합니다.
반응형
'JAVA & Spring' 카테고리의 다른 글
[Spring Security] WebSecurityConfiguration 총정리 (0) | 2023.09.12 |
---|---|
[postman][Spring] JPA 라이브러리로 API 전송 시 NULL 값 발생 해결 방법 (0) | 2023.08.26 |
[JAVA] JFrame을 이용한 계산기 만들기 (소스 코드) (0) | 2023.08.03 |
[JAVA] 마름모 출력 소스 코드 (0) | 2023.08.02 |
[Java / MySQL] 도서 관리 시스템 04 (MVC패턴)(마무리) (0) | 2023.02.04 |
댓글