공부/JSP
[JSP] 쉽게 배우는 JSP 웹 프로그래밍 9장 연습문제
thegreatjy
2020. 11. 3. 00:00
728x90
4번
(1) locale.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="UTF-8"%>
<%@page import="java.util.Locale" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%Locale locale=request.getLocale(); %>
<h3>현재 로케일</h3>
<p>언어:<%=locale.getLanguage() %>
<p>국가:<%=locale.getCountry() %>
</body>
</html>
|
cs |
mvnrepository.com/artifact/javax.servlet/jstl/1.2
jar 파일 다운로드 후 WEB-INF/lib에 넣는다.
5번
(1) jstl_fmt.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<fmt:setLocale value='<%=request.getParameter("language") %>'/>
<fmt:bundle basename="ch09.com.bundle.newBundle">
<a href="?language=ko">Korean</a>|<a href="?language=en">English</a>
<form action="#">
<p><fmt:message key="id"/> : <input type="text" name="id">
<p><fmt:message key="password"/> : <input type="text" name="pw">
<p><input type="button" value="<fmt:message key="button"/>">
</form>
</fmt:bundle>
</body>
</html>
|
cs |
(2) Java Resources/src/ch09.com.bundle/newBundle.properties
Java Resources/src/ch09.com.bundle/newBundle_en.properties
##package 만들 때, /src/
1
2
3
|
id=아이디
password=비밀번호
button=전송
|
cs |
1
2
3
|
id=id
password=password
button=button
|
cs |
6번
(1) addBook.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
<%@ page language="java" contentType="text/html; charset=utf-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html>
<head>
<title>Insert title here</title>
</head>
<link rel="stylesheet" href="./resources/css/bootstrap.min.css">
<script type="text/javascript" src="./resources/js/validation.js"></script>
<body>
<fmt:setLocale value='<%= request.getParameter("language") %>'/>
<fmt:bundle basename="bundle.message">
<jsp:include page="menu.jsp"/>
<div class="jumbotron">
<div class="container">
<h1 class = "display-3"><fmt:message key="title"/></h1>
</div>
</div>
<div class="container">
<div class="text-right">
<a href="?language=ko">Korean</a>|<a href="?language=en">English</a>
</div>
<form name="newBook" action="./processAddBook.jsp" class="form-horiontal" method="post"
enctype="multipart/form-data">
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="bookId"/></label>
<div class="col-sm-3">
<input type="text" id="productId" name="bookId" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="name"/></label>
<div class="col-sm-3">
<input type="text" id="name" name="name" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="unitPrice"/></label>
<div class="col-sm-3">
<input type="text" id="unitPrice" name="unitPrice" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="author"/></label>
<div class="col-sm-3">
<input type="text" name="author" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="publisher"/></label>
<div class="col-sm-3">
<input type="text" name="publisher" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="releaseDate"/></label>
<div class="col-sm-3">
<input type="text" name="releaseDate" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="totalPages"/></label>
<div class="col-sm-3">
<input type="text" name="totalPages" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="description"/></label>
<div class="col-sm-5">
<textarea name="description" cols="50" rows="2" class="form-control"></textarea>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="category"/></label>
<div class="col-sm-3">
<input type="text" name="category" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="unitsInStock"/></label>
<div class="col-sm-3">
<input type="text" id="unitsInStock" name="unitsInStock" class="form-control">
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="condition"/></label>
<div class="col-sm-5">
<input type="radio" name="condition" value="New"> <fmt:message key="condition_New"/>
<input type="radio" name="condition" value="Old"> <fmt:message key="condition_Old"/>
<input type="radio" name="condition" value="E-Book"> <fmt:message key="condition_Refurbished"/>
</div>
</div>
<div class="form-group row">
<label class="col-sm-2"><fmt:message key="bookImage"/></label>
<div class="col-sm-5">
<input type="file" name="productImage" class="form-control">
</div>
</div>
<div class="form-group row">
<div class="col-sm-offset-2 col-sm-10">
<input type="button" value="<fmt:message key="button"/>" class="btn btn-primary" onclick="CheckAddProduct()">
</div>
</div>
</form>
</div>
</fmt:bundle>
</body>
</html>
|
cs |
(2) src/bundle/message.properties
src/bundle/message_en.properties
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
title=도서 등록
bookId=도서 아이디
name=도서명
unitPrice=가격
author=저자
description=상세 설명
publisher=출판사
category=분류
unitsInStock=재고 수
totalPages=총 페이지 수
releaseDate=출판일
condition=상태
bookImage=이미지
condition_New=신규 도서
condition_Old=중고 도서
condition_Refurbished=E-Book
button=등록
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
title=Book Addition
bookId=Book ID
name=Name
unitPrice=Unit Price
author=Author
description=Description
publisher=Publisher
category=Category
unitsInStock=Units In Stock
totalPages=Total Pages
releaseDate=Release Date
condition=Condition
bookImage=Image
condition_New=New
condition_Old=Old
condition_Refurbished=E-Book
button=Insert
|
cs |
728x90