JSP ์์ธ ์ฒ๋ฆฌ ํ์ด์ง
์๋ต ์ํ ์๋ฌ ์ฝ๋๋ณ ์์ธ ์ฒ๋ฆฌ ํ์ด์ง
404 ํ์ด์ง ๋ง๋ค๊ธฐ
โข
web.xml
<error-page>
<error-code>404</error-code>
<location>/error/404.jsp</location>
</error-page>
XML
๋ณต์ฌ
โข
404.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>
<h1>404 ์๋ฌ ํ์ด์ง</h1>
<div>
<p>ํ์ด์ง๋ฅผ ์ฐพ์ ์ ์์ต๋๋ค.</p>
<h5>์์ฒญ ๊ฒฝ๋ก๋ฅผ ํ์ธํด์ฃผ์ธ์.</h5>
<div>
<a href="<%= request.getContextPath() %>">๋ฉ์ธ ํ๋ฉด</a>
</div>
</div>
</body>
</html>
HTML
๋ณต์ฌ
500 ํ์ด์ง ๋ง๋ค๊ธฐ
โข
web.xml
<error-page>
<error-code>500</error-code>
<location>/error/500.jsp</location>
</error-page>
XML
๋ณต์ฌ
โข
500.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>
<h1>500 ์๋ฌ ํ์ด์ง</h1>
<div>
<p>์์คํ
์ผ์์ ์ธ ์๋ฌ๊ฐ ๋ฐ์ํ์์ต๋๋ค.</p>
<h5>๊ด๋ฆฌ์์๊ฒ ๋ฌธ์ํด์ฃผ์ธ์</h5>
<div>
<a href="<%= request.getContextPath() %>">๋ฉ์ธ ํ๋ฉด</a>
</div>
</div>
</body>
</html>
HTML
๋ณต์ฌ
โข
500 ์๋ฌ ๋ง๋ค๊ธฐ
โฆ
exception.jsp
โฆ
exception_pro.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>500 ์๋ฌ ๋ง๋ค๊ธฐ</title>
</head>
<body>
<form action="exception_pro.jsp" method="post">
<p> ์ซ์1 : <input type="text" name="num1">
<p> ์ซ์2 : <input type="text" name="num2">
<p> <input type="submit" value="๋๋๊ธฐ">
</form>
</body>
</html>
HTML
๋ณต์ฌ
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>500 ์๋ฌ ๋ง๋ค๊ธฐ</title>
</head>
<body>
<%
String num1 = request.getParameter("num1");
String num2 = request.getParameter("num2");
int a = Integer.parseInt(num1);
int b = Integer.parseInt(num2);
int c = a / b;
out.print(num1 + " / " + num2 + " = " + c);
%>
</body>
</html>
HTML
๋ณต์ฌ
์์ธ ๋ณ ์ฒ๋ฆฌ ํ์ด์ง ๋ง๋ค๊ธฐ
โข
web.xml
<error-page>
<exception-type>java.lang.Exception</exception-type>
<location>/error/exception.jsp</location>
</error-page>
XML
๋ณต์ฌ
โข
exception.jsp
<h1>์์ธ ์๋ฌ ํ์ด์ง</h1>
<h3>์์คํ
์์
์ฒ๋ฆฌ ์ค ์์ธ๊ฐ ๋ฐ์ํ์์ต๋๋ค.</h3>
<a href="<%= request.getContextPath() %>">๋ฉ์ธ ํ๋ฉด</a>
XML
๋ณต์ฌ