include 디렉트브 - <%@ include file="포함 될 파일의 url"%>
공통적으로 포함 될 내용을 가진 파일을 해당 JSP페이지 내에 삽입하는 기능을 제공한다.
여러 포함 될 페이지들을 포함하는 페이지에 include디렉티브를 이용해 넣어주면 여러페이지를 한페이지로 합쳐서 인식되어 변환되고 컴파일 된다.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
import="java.sql.Timestamp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>top.jsp</title>
</head>
<body>
<%
Timestamp now = new Timestamp(System.currentTimeMillis());
%>
<%=now.toString() %><p>
<b><%="top.jsp 페이지" %></b>
<hr>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>bottom.jsp</title>
</head>
<body>
<hr>
bottom.jsp입니다.<p>
<!-- =%name이 오류라고 뜨지만 읽어들이는 페이지에 name변수 선언이 되어있으면 잘 작동된다. -->
작성자는 <b><%=name%></b>입니다.<p>
<b><%="bottom.jsp 페이지" %></b>
<hr>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>include 디렉티브 연습</title>
</head>
<body>
<h2>include 디렉티브 연습</h2>
<%
String name= "Kim";
%>
<%@include file="module/top.jsp" %>
포함하는 페이지 includeDirective.jsp의 내용입니다.
<%@include file="module/bottom.jsp" %>
</body>
</html>
include코드를 작성한 곳에 top.jsp, bottom.jsp의 소스코드를 복사한 후 같이 변환되어 컴파일 된다.
'프로그래밍언어 > JSP' 카테고리의 다른 글
[JSP] page Directive (0) | 2021.11.03 |
---|---|
[JSP] JSP 주석 (0) | 2021.10.19 |
[JSP] JSTL & 사용자 정의 태그 (0) | 2021.10.19 |
[JSP] 표현 언어(expression language) (0) | 2021.09.13 |
[JSP] 액션 태그(action tags) (0) | 2021.09.12 |
include 디렉트브 - <%@ include file="포함 될 파일의 url"%>
공통적으로 포함 될 내용을 가진 파일을 해당 JSP페이지 내에 삽입하는 기능을 제공한다.
여러 포함 될 페이지들을 포함하는 페이지에 include디렉티브를 이용해 넣어주면 여러페이지를 한페이지로 합쳐서 인식되어 변환되고 컴파일 된다.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
import="java.sql.Timestamp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>top.jsp</title>
</head>
<body>
<%
Timestamp now = new Timestamp(System.currentTimeMillis());
%>
<%=now.toString() %><p>
<b><%="top.jsp 페이지" %></b>
<hr>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>bottom.jsp</title>
</head>
<body>
<hr>
bottom.jsp입니다.<p>
<!-- =%name이 오류라고 뜨지만 읽어들이는 페이지에 name변수 선언이 되어있으면 잘 작동된다. -->
작성자는 <b><%=name%></b>입니다.<p>
<b><%="bottom.jsp 페이지" %></b>
<hr>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>include 디렉티브 연습</title>
</head>
<body>
<h2>include 디렉티브 연습</h2>
<%
String name= "Kim";
%>
<%@include file="module/top.jsp" %>
포함하는 페이지 includeDirective.jsp의 내용입니다.
<%@include file="module/bottom.jsp" %>
</body>
</html>
include코드를 작성한 곳에 top.jsp, bottom.jsp의 소스코드를 복사한 후 같이 변환되어 컴파일 된다.
'프로그래밍언어 > JSP' 카테고리의 다른 글
[JSP] page Directive (0) | 2021.11.03 |
---|---|
[JSP] JSP 주석 (0) | 2021.10.19 |
[JSP] JSTL & 사용자 정의 태그 (0) | 2021.10.19 |
[JSP] 표현 언어(expression language) (0) | 2021.09.13 |
[JSP] 액션 태그(action tags) (0) | 2021.09.12 |