에러&문제해결

HTTP 상태 500 - 내부서버오류 | NumberFormatException

보배 진 2025. 11. 17. 09:16

 

 

<%@ 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>

<%
	int a = Integer.parseInt("apple");
%>
</body>
</html>

 

 

 

5nn : 서버 개발자 자바의 문제이다

-> 자바의 문제였다

 

근본원인 또는 콘솔 창을 보는 걸 추천한다

NumberFormatException 

apple을 어떻게 숫자로 바꾸니

 

 

프로그램의 비정상적 중단을 막기 위해 예외처리를 한다

 

 


 

 

< error 페이지 추가하기>

NewFile.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" errorPage="error/error.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>

<%
	int a = Integer.parseInt("apple");
%>
</body>
</html>

 

 

 

 

error.jsp

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

<h1>에러가 발생했습니다!</h1>
<h3>관리자에게 문의해주세요...</h3>

</body>
</html>

 

url을 보면 나의 것인데 에러 페이지만 보여주는 것이다

에러를 막는 것이 아니라 에러가 나더라도 페이지를 다른 것을 보내 비정상적인 종료를 막고

해당 서비스를 끊김없이 이용할 수 있도록 한다