본문 바로가기
Backend/JSP

[JSP] 'Starting Tomcat v9.0 Server at localhost' has encountered a problem 오류 확인

by 그적 2020. 11. 4.

아래 있는 코드들을 실행시켜본다. 아래 있는 코드가 잘되면 본인의 코드가 틀린 것이다.

실행시킬 때, security01.jsp를 RUN 해줘야 한다.

 

(※ 주의할 점 : 이전에 시도한 세션이 유지되어서는 안 된다. 따라서 콘솔 창 라인에 있는 Server 창에서 빨간 버튼을 눌러 서버를 꺼준 후, 다시 Run을 해야 한다. Stopped 된 상태에서 Run 하자.)

파일 구성은 아래와 같다.

 

// security01.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Security</title>
</head>
<body>

<p> 인증 성공했습니다.

</body>
</html>

 

// login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Security</title>
</head>
<body>

<form name="loginForm" action="j_security_check" method="post">
<p> 사용자명: <input type="text" name="j_username">
<p> 비밀번호: <input type="password" name="j_password">
<p> <input type="submit" value="전송">
</form>

</body>
</html>

 

// login_failed.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Security</title>
</head>
<body>

<p> 인증 실패했습니다.

</body>
</html>

 

// web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
	<security-role>
		<role-name>role1</role-name>
	</security-role>
	<security-constraint>
		<web-resource-collection>
			<web-resource-name>JSPBook</web-resource-name>
			<url-pattern>/ch10/security01.jsp</url-pattern>
			<http-method>GET</http-method>
		</web-resource-collection>
		<auth-constraint>
			<description></description>
			<role-name>role1</role-name>
		</auth-constraint>
	</security-constraint>
	<login-config>
		<auth-method>FORM</auth-method>
		<form-login-config>
			<form-login-page>/ch10/login.jsp</form-login-page>
			<form-error-page>/ch10/login_failed.jsp</form-error-page>
		</form-login-config>
	</login-config>
</web-app>

댓글