관리 메뉴

거니의 velog

231030_JSP 과제 2 본문

대덕인재개발원_웹기반 애플리케이션

231030_JSP 과제 2

Unlimited00 2023. 10. 30. 12:42

[p. 102-104]




<%@page import="java.util.Date"%>
<%@page import="java.lang.Math"%>
<%@ 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>
		<%! 
			Date today = new Date();
			double pow5 = Math.pow(5, 2);
		%>
		<p>현재 날짜 : <%= today %></p>
		<p>5의 제곱 : <%= pow5 %></p>
	</body>
</html>

- http://localhost/page.jsp


[header.jsp]

<%@ 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>
		<h4>Hello, Java Server Pages.</h4>
	</body>
</html>

[include.jsp]

<%@page import="java.util.Date"%>
<%@page import="java.util.Calendar"%>
<%@ 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>
		<%@ include file="header.jsp" %>
		<%! 
			Calendar todayCal = Calendar.getInstance();
			Date todayDate = todayCal.getTime();
		%>
		<p>현재 시간 : <%= todayDate %></p>
	</body>
</html>

- http://localhost/include.jsp


[taglib.jsp]

<%@ 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>Insert title here</title>
	</head>
	<body>
		<c:forEach var="k" begin="0" end="10" step="1">
			<c:if test="${ k % 2 == 0 }">
				<c:out value="${k}" />
			</c:if>
		</c:forEach>
	</body>
</html>

- http://localhost/taglib.jsp


[menu.jsp]

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
		<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>

[footer.jsp]

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
		<footer class="container">
			<p>&copy; BookMarket</p>
		</footer>

[welcome.jsp]

<%@ 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>Insert title here</title>
		<link rel="stylesheet" href="/resources/css/bootstrap.min.css" />
	</head>
	<body>
		<%@ include file="menu.jsp" %>
		<% 
			String greeting = "도서 웹 쇼핑몰";
			String tagline = "Welcome to Book Market!";
		%>
		<div class="jumbotron">
			<div class="container">
				<h1 class="display-3"><%= greeting %></h1>
			</div>
		</div>
		<div class="container">
			<div class="text-center">
				<h3><%= tagline %></h3>
			</div>
			<hr />
		</div>
		<%@ include file="footer.jsp" %>
	</body>
</html>

- http://localhost/welcome.jsp

'대덕인재개발원_웹기반 애플리케이션' 카테고리의 다른 글

231031_JSP 과제 정리  (0) 2023.10.31
231031_JSP 개론 4  (0) 2023.10.31
231030_JSP 개론 3  (0) 2023.10.30
231027_JSP 과제 1  (0) 2023.10.27
231027_JSP 개론 2  (0) 2023.10.27