JSP태그로 Header와 Footer 처리하기

Main.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<jsp:include page="10_header.jsp"/> 
메인 화면입니다. <br> 
<a href="10_sub.jsp">서브 페이지로 이동</a> 
<jsp:include page="10_footer.jsp"/> 
</body> 
</html>

Header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<h3> 이부분은header입니다.</h3> 
<hr>

Footer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<hr> 
<h4> 이부분은footer입니다.</h4>

 

Sub.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
<jsp:include page="10_header.jsp"/> 
서브 화면입니다. <br> 
<a href="10_main.jsp">메인 페이지로 되돌아가기</a> 
<jsp:include page="10_footer.jsp"/> 
</body> 
</html>