티스토리 뷰

web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app>

	<security-role>
		<description></description>
		<role-name>manager</role-name>
	</security-role>
	<security-constraint>
		<display-name>WebMarket Security</display-name>
		<web-resource-collection>
			<web-resource-name>WebMarket</web-resource-name>
			<description></description>
			<url-pattern>/addproduct.jsp</url-pattern>
		</web-resource-collection>
		<auth-constraint>
			<description>권한 관리자명</description>
			<role-name>manager</role-name>
		</auth-constraint>
	</security-constraint>
	<login-config>
		<auth-method>FORM</auth-method>
		<form-login-config>
			<form-login-page>/login.jsp</form-login-page>
			<form-error-page>/login_failed.jsp</form-error-page>
		</form-login-config>
	</login-config>
</web-app>

 

 

login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Insert title here</title>
</head>
<body>
	<jsp:include page="menu.jsp"/>
	<div class="jumbotron">
		<div class="container">
			<h1 class="display-3">로그인</h1>
		</div>
	</div>
	<div class="container" align="center">
		<div class="col-md-4 col-md-offset-4">
			<h3 class="form-signin-heading">Please sign in</h3>
			<%
				String error=request.getParameter("error");
				if(error!=null){
					out.println("<div class='alert alert-danger'>");
					out.println("아이디와 비밀번호를 확인해주세요.");
					out.println("</div>");
				}
			%>
			<form class="form-signin" action="j_security_check" method="post">
				<div class="form-group">
					<label for="inputusername" class="sr-only">User Name</label>
					<input type="text" class="form-control" placeholder="ID" name='j_username' required autofocus>
				</div>
				<div class="form-group">
					<label for="inputpassword" class="sr-only">Password</label>
					<input type="password" class="form-control" placeholder="Password" name='j_password' required>
				</div>
				<button class="btn btn btn-lg btn-success btn-block" type="submit">로그인</button>		
			</form>
		</div>
	</div>
</body>
</html>

 

login_failed.jsp

<%
	response.sendRedirect("login.jsp?error=1");
%>

 

logout.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	session.invalidate();
	response.sendRedirect("addproduct.jsp");
%>

 

addproduct.jsp 추가부분

	<div class="container">
		<div class="text-right">
			<a href="?language="ko" >Korean</a>|<a href="?language=en">English</a>
			<a href="logout.jsp" class="btn btn-sm btn-success pull-right">logout</a>	
		</div>

 

 

로그인 페이지

 

 

공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday