slide-image
728x90

1. 오류 페이지 작성하기

exceptionNoProduct.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>상품 아이디 오류</title>
<link rel="stylesheet" href="./resource/css/bootstrap.css" />
</head>
<body>
	<jsp:include page="Menu.jsp" />
	<div class="jumbotron">
		<div class="container">
			<h2 class="alert alert-danger">해당 상품이 존재하지 않습니다</h2>
		</div>
	</div>

	<div class="container">
		<p><%=request.getRequestURL() %>?<%=request.getQueryString() %>
		<P><a href="products.jsp" class="btn btn-secondary">상품 목록 &raquo;</a>
	</div>
</body>
</html>

 

2. 상품 상세 보기 페이지 수정하기

Product.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="DTO.Product" %>
<%@ page import="DAO.ProductRepository" %>
<%@ page errorPage="exceptionNoProductId.jsp" %>

<jsp:useBean id="productDAO" class="DAO.ProductRepository" scope="session" />

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>상품 상세 정보</title>
<link rel="stylesheet" href="./resources/css/bootstrap.min.css">
</head>
<body>
		<%@ include file="Menu.jsp" %>
		
		<div class="jumbotron">
			<div class="container">
				<h1 class="display-3">
					상품 정보
				</h1>
			</div>
		</div>
		
		<%
			String id = request.getParameter("id");
			ProductRepository dao = ProductRepository.getInstance();
			Product product = productDAO.getProductById(id);	
		%>
		
		<div class="container">
			<div class="row">
				<div class="col-md-5">
					<img src="./upload/<%=product.getFilename()%>"style="width:100%" />
				</div>
			
				<div class="col-md-6">
					<h3><%=product.getPname() %></h3>
					<p><%=product.getDescription() %>
					<p><b>상품 코드: </b>
					<span class="bagde badge-danger">
						<%=product.getProductId() %>
					</span>
					<p><b>제조사: </b><%=product.getManufacturer() %>
					<p><b>분류: </b><%=product.getCategory() %>
					<p><b>재고: </b><%=product.getUnitsInStock() %>
					<h4><%=product.getUnitPrice() %>원</h4>
					<p><a href="#" class="btn btn-info">상품 주문  &raquo;</a>
					<a href="./Products.jsp" class="btn btn-secondary">상품 목록  &raquo;</a>
				</div>
			</div>
			<hr>
		</div>
		
		<%@ include file="Footer.jsp" %>
</body>
</html>

 

3. web.xml 파일에 추가 작성하기

web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app>
	<security-role>
		<description></description>
		<role-name>admin</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>admin</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>
	<error-page>
		<error-code>404</error-code>
		<location>/exceptionNoPage.jsp</location>
	</error-page>
</web-app>

 

4. 오류 페이지 작성하기

exceptionNoPage.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>페이지 오류</title>
<link rel="stylesheet" href="./resource/css/bootstrap.css" />
</head>
<body>
	<jsp:include page="Menu.jsp" />
	<div class="jumbotron">
		<div class="container">
			<h2 class="alert alert-danger">요청하신 페이지를 찾을 수 없습니다</h2>
		</div>
	</div>

	<div class="container">
		<p><%=request.getRequestURL() %></p>
		<p><a href="products.jsp" class="btn btn-secondary">상품 목록 &raquo;</a></p>
	</div>
</body>
</html>

WebMarket(11).zip
0.75MB

 

 

728x90
반응형