프로그래밍/JSP Servlet

JSP/Servlet - <jsp:include> 표준액션의 사용 방법

가카리 2016. 1. 14. 21:55
반응형

 

JSP/Servlet - <jsp:include> 표준액션의 사용 방법

 

<jsp:include>는 JSP페이지에 다른 웹자원을 포함시키고자 할 때 사용하는 표준 액션 입니다.

 

 

 

Info.jsp

 

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<!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=EUC-KR">

<title>Insert title here</title>

</head>

<body>

    표준 액션 예제입니다.<BR>

    <jsp:include page="Copyright.html"/>

</body>

</html>

 

 

Copyright.html

 

<font size=3>추가한 내용이요</font>

 

 

실행 화면

실행하면 다음과 같이 include가 잘됨을 알 수 있습니다.

 

 

이번에는 jsp를 include해봅시다.

 

Winners.jsp

 

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<!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=EUC-KR">

<title>Insert title here</title>

</head>

<body>

    수상자 <BR>

    gakari <br>

    the pillows <br>

    love psychedelico <br>

    <jsp:include page="Now.jsp"/>    

</body>

</html>

 

 

Now.jsp

 

<%@ page language="java" contentType="text/html; charset=EUC-KR"

pageEncoding="EUC-KR"%>

<%@page import="java.util.*" %>

<%

    GregorianCalendar now = new GregorianCalendar();

    String date = String.format("%TY %Tm %Td", now, now, now);

    String time = String.format("%Tp %TR", now, now);

%>

 

시간 <%=date %> <%= time %>

 

실행 화면

jsp파일을 잘 불러온 것을 확인 할 수 있습니다.

반응형