3장 연습문제 소스코드
3장 연습문제
1. 다음 중 디렉티브 태그로 사용하는 형식은 무엇인가?
- 3번 : <%@ ... %>
2. 다음 중 스크립트 태그의 종류와 형식으로 옳지 않은 것은 무엇인가?
- 3번 : taglib 태그 :<%@ taglib= ... %>
- 4번 : action 태그: <%@ action ... &>
3. JSP 페이지가 사용할 자바 클래스를 설정하기 위한 page 디렉티브 태그의 속성은 무엇인가?
- 2번 : import
4. JSP 페이지의 특정 영역에 다른 외부 파일의 내용을 포함하는 디렉티브 태그는 무엇인가?
- 2번 : include 디렉티브 태그
5.JSP 페이지에 표현 언어, JSTL 사용자 정의 태그(custom tag) 등 태그 라이브러리를 설정하는 디렉티브 태그는 무엇인가?
- 3번 : taglib 디렉티브 태그
6. 다음 프로그램의 밑줄에 들어갈 올바른 것은 무엇인가?
- 2번 : import
7. 다음 프로그램의 밑줄에 들어갈 올바른 것은 무엇인가?
- 3번 : taglib
소스 코드
8.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.Date" %>
<%@ page import="java.lang.Math" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Directive Tag</title>
</head>
<body>
<%
Date currentDate = new Date();
double result = Math.pow(5, 2);
%>
<h2>현재 날짜: <%= currentDate %></h2>
<h2>5의 제곱: <%= result %></h2>
</body>
</html>
9.
header.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Directive Tag</title>
</head>
<body>
<h1>Hello.Java Server Pages</h1>
</body>
</html>
include.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.Calendar" %>
<%@ include file="header.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Directive Tag</title>
</head>
<body>
<%@ include file="header.jsp" %>
현재 시간 : <%= java.util.Calendar.getInstance().getTime() %>
</body>
</html>
10.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Directive Tag</title>
</head>
<body>
<c:forEach begin="0" end="10" step="2" var="i">
<c:out value="${i}" />
<c:if test="${not empty i and i ne 10}">,</c:if>
</c:forEach>
</body>
</html>
'프로그래밍 > JSP' 카테고리의 다른 글
[쉽게 배우는 JSP 웹프로그래밍 개정2판] 6장 설명, 연습문제 (0) | 2024.06.04 |
---|---|
[쉽게 배우는 JSP 웹프로그래밍 개정2판] 5장 설명, 연습문제 (1) | 2024.06.03 |
[쉽게 배우는 JSP 웹프로그래밍 개정2판] 4장 설명, 연습문제 (0) | 2024.06.02 |
[쉽게 배우는 JSP 웹프로그래밍 개정2판] 2장 설명, 연습문제 (0) | 2024.05.05 |
[쉽게 배우는 JSP 웹프로그래밍 개정2판] 1장 설명, 연습문제 (0) | 2024.05.04 |
댓글