공부/JSP
[JSP] 쉽게 배우는 JSP 웹 프로그래밍 3장 연습문제
thegreatjy
2020. 9. 25. 20:30
728x90
4번
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page import="java.util.Date, java.lang.Math" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>page</title>
</head>
<body>
<%
Date day=new Date();
out.println("현재 날짜 : "+day.toString()+"<br>");
out.println("5의 제곱 : "+Math.pow(5,2));
%>
</body>
</html>
|
cs |
5번
(1) header.jsp
1
2
3
4
5
6
7
8
9
10
11
12
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>header</title>
</head>
<body>
<h4>Hello, Java Server Pages.</h4>
</body>
</html>
|
cs |
(2) include.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ page import="java.util.Calendar" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>IncludeJSP</title>
</head>
<body>
<%@ include file="header.jsp" %>
<%
out.println("현재 시간 : "+Calendar.getInstance().getTime());
%>
</body>
</html>
|
cs |
6번
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>TagLibJSP</title>
</head>
<body>
<c:forEach var="k" begin="0" end="10" step="2">
<c:out value="${k}"/>
</c:forEach>
</body>
</html>
|
cs |
7번
(1) menu.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>MenuJSP</title>
</head>
<body>
<nav class="navbar navbar-expand navbar-dark bg-dark">
<div class = "container">
<div class = "navbar-header">
<a class = "navbar-brand" href="./welcome.jsp">Home</a></div></div>
</nav>
</body>
</html>
|
cs |
(2) footer.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>FooterJSP</title>
</head>
<body>
<footer class="container">
<p> © BookMarket</p>
</footer>
</body>
</html>
|
cs |
(3) welcome.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Welcome</title>
</head>
<!-- 합쳐지고 최소화된 최신 CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<body>
<%@ include file="menu.jsp" %>
<%!
String str1="도서 웹 쇼핑몰";
String str2="Welcome to Book Market!";
%>
<div class="jumbotron">
<div class="container">
<h1 class = "display-3">
<%= str1 %>
</h1>
</div>
</div>
<div class="container">
<div class="text-center">
<p>
<%= str2 %>
<p>
<hr>
</div>
</div>
<%@ include file="footer.jsp" %>
</body>
</html>
|
cs |
잘못된 부분 있으면 댓글로 알려주세요!
쉽게 배우는 jsp 웹 프로그래밍 3장 연습문제
728x90