JSP

(JSP) Scope & Attribute개념정리 action태그- include 예제

김만식이 2020. 8. 28. 14:07

jsp에서 제공하는 내장 개게들중 page session request application 들은 해당 객체에 정의된 유효 범위 안넹서 서로 다른 페이지라 할지라도 필요한 객체(데이터)들을 저장하고 읽어 들임으로써 서로 공유 할 수 있는 특정한 공간을 가지고 있다. 

공유되는 데이터를 속성 (Attrubute) 라고 한다. 

 

include 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("UTF-8");
%>
<%
	String check;
	check = (String) request.getParameter("name");
	if (check == null) {
		check = "newitem";
	}
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- 합쳐지고 최소화된 최신 CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">

<!-- 부가적인 테마 -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">

<!-- 합쳐지고 최소화된 최신 자바스크립트 -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
</head>
<body >
<table border="1">

<tr>
<td colspan="3"><jsp:include page="top.jsp"/></td>
</tr>

<tr>
<td><jsp:include page="left.jsp"/></td>
</tr>

<tr>
<td><jsp:include page='<%=check+".jsp"%>'/></td>
</tr>
<tr>
<td><jsp:include page="footer.jsp"/></td>
</tr>
</table>
</body>
</html>
<%@ 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>
신상품 테스트
</body>
</html>
<%@ 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>
베스트상품
</body>
</html>
<%@ 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>

<a href="template.jsp?name=newitem">신상품</a><br/>
<a href="template.jsp?name=bestitem">인기상품</a> 

</body>
</html>