WEB/JSP
JSP 22 - 쇼핑몰 만들기(8) (예외 처리 하기)
inderrom
2023. 1. 13. 12:45
상세보기 페이지 상단에
page 디렉티브 추가
<product.jsp>
<%@ page errorPage="exceptionNoProductId.jsp" %>
<exceptionNoProductId.jsp>
<%@ page language="java" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="/css/bootstrap.min.css">
<title>상품 아이디 오류</title>
</head>
<body>
<!-- include 액션 태그 -->
<jsp:include page="menu.jsp" />
<!-------------- 예외처리 시작 ------------------->
<div class="jumbotron">
<!-- container : 이 안에 내용 있다. -->
<div class="container">
<h1 class="display-3">해당 상품이 존재하지 않습니다.</h1>
</div>
</div>
<div class="container">
<!--
request.getRequestURL() : 해당 오류 페이지의 주소
request.getQueryString() : 요청 파라미터 정보
-->
<p><%=request.getRequestURL()%>?<%=request.getQueryString() %></p>
<p><a href="products.jsp" class="btn btn-secondary">상품 목록»</a></p>
</div>
<jsp:include page="footer.jsp" />
</body>
</html>