[Day5] JSP/Servlet 5 [12/8]
p 132 JSP ๊ธฐ๋ณธ ๊ฐ์ฒด์ 4๊ฐ์ง์ ์์ญ( scope )
1) ํ ํ์ด์ง ์ฌ์ฉ๋๋ ์์ญ : page scope(์์ญ) - page[Context] ๊ฐ์ฒด
ex01.html -> page scope
2) ํ๋์ ์์ฒญ์ ์ฌ์ฉ๋๋ ์์ญ : request scope - request ๊ฐ์ฒด
ex01.html -> r ํฌ์๋ฉ r ex01.jsp
<-
3) ๋ธ๋ผ์ฐ์ ex01.02.03. ์ฌ๋ฌ ๋ฒ ์์ฒญ : session scope - session ๊ฐ์ฒด (๋ธ๋ผ์ฐ์ ๋ซ๊ธฐ์ ์ ๊ณ์ ์ฌ์ฉ๊ฐ๋ฅ ๊ณต๊ฐ)
4) ๋ชจ๋ ํด๋ผ์ด์ธํธ(๋ธ๋ผ์ฐ์ ) ๊ฐ ๊ณต์ ํด์ ์ฌ์ฉํ๋ ์์ญ : application ์์ญ - application ๊ฐ์ฒด
(๋ธ๋ผ์ฐ์ ์๊ด์์ด ๋ชจ๋ ์ฌ๋ ์์ฒญํด์ ๊ณต์ ํ๋ ์์ญ)
๊ทธ๋ฆผ 5.11 ๋ค ๊ฐ์ง ์์ญ๊ณผ ๊ธฐ๋ณธ ๊ฐ์ฒด์์ ๊ด๊ณ.
p 135 ์์ฑ ๋ฉ์๋
setAttribute();
getAttribute();
getAttributeNames()
removeAttribute( name )
-ex01_02.jsp-
<%
// 4๊ฐ์ง ์์ญ(scope) ๊ฐ๊ฐ ๊ฐ์ ์ ์ฅ.
application.setAttribute("name", "admin");
session.setAttribute("age", 20);
request.setAttribute("addr", "seoul");
pageContext.setAttribute("tel", "010-");
%>
a name : <%= application.getAttribute("name") %><br>
s age : <%= session.getAttribute("age") %><br>
r addr : <%= request.getAttribute("addr") %><br>
p tel : <%= pageContext.getAttribute("tel" ) %><br>
<br>
<a href="ex01_03.jsp">ex01_03.jsp</a>
a name , s age O
r addr , p tel X
* ์๋์ด
-ex01_03.jsp-
a name : <%= application.getAttribute("name") %><br>
s age : <%= session.getAttribute("age") %><br>
r addr : <%= request.getAttribute("addr") %><br>
p tel : <%= pageContext.getAttribute("tel" ) %><br>
* ์ดํ๋ฆฌ์ผ์ด์ & ์ธ์ : ๋์ด
* ๋ฆฌํ์คํธ & ํ์ด์ง์ปจํ ์คํธ : ์๋์ด
-ex01_04.jsp-
a name : <%= application.getAttribute("name") %><br>
<!--
์ธ์
์ ๊ฐ์ ๋ก ์ข
๋ฃํ์ง ์๋ ๋์
์ ์ํ ์ฌ์ฉ์๋ง ๊ณ์ ์ฌ์ฉํ ์ ์๋ ์์ญ์ด ์ธ์
์ด๋ผ๋ ์์ญ์ด๊ณ
์ธ์ฆ, ๊ถํ, ์ฅ๋ฐ๊ตฌ๋ ๋ฑ๋ฑ ๊ตฌํ
-->
s age : <%= session.getAttribute("age") %><br>
r addr : <%= request.getAttribute("addr") %><br>
p tel : <%= pageContext.getAttribute("tel" ) %><br>
* ํฌ๋กฌ ๋ค ๋ซ๊ณ ๋ค์ ๋์ฐ๋ฉด -> ์ดํ๋ฆฌ์ผ์ด์ ๋ง ์ด์์์ (์๋ฒ๊ฐ ์ด์์๋ ํ)
* ์๋ฒ ํด๋ฆฐํ๊ณ ๋ค์ ์์ํ๋ฉด ์์
*** request, session -> ๋ง์ด์ / application ์ข ์
- MVC์์ request
- ๋ก๊ทธ์ธ,๋ก๊ทธ์์ session
p139 Chapter 06 ์๋ฌ ์ฒ๋ฆฌ
1. ์์ธ ์ฒ๋ฆฌ
2. ์๋ฌ ํ์ด์ง
3. ์ํ ์ฝ๋(404, 500)์ ์์ธ ํ์ ๋ณ ์๋ฌ ํ์ด์ง ์ง์
name ํ๋ฆฌ๋ฏธํฐ ๊ฐ :
<%
try{
%>
<%= request.getParameter("name").toUpperCase() %>
<%
}catch(Exception e ){
%>
name ํ๋ผ๋ฏธํฐ๊ฐ ์ฌ๋ฐ๋ฅด์ง ์์ต๋๋ค.
<%
}
%>
* 500 : ์๋ฐ์๋ฌ
* ์์ธ ๋ฐ์ํ ๋
์์ ๊ฐ์ด ์ผ๋ถ๋ง try~catch ๋ฌธ์ผ๋ก ์์ธ ์ฒ๋ฆฌํ ๊ฒ์ด ์๋๋ผ.
์์ธ ์ฒ๋ฆฌ ํ์ด์ง( ์๋ฌ ํ์ด์ง )๋ก ์ด๋...!
p 143 ์๋ฌ ํ์ด์ง ์ง์ ํ๊ธฐ.
ex02_02.jsp
ex02_02.jsp ํ์ด์ง์์ ๋ง์ฝ์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ฉด
errorPage ์์ฑ์ ์ง์ ๋ ํ์ด์ง๋ก ์ด๋...ํ๋ค.
viewErrorMessage.jsp ํ์ผ์ WEB-INF ํด๋ > jsp ํด๋ ์ผ๋ก ์ด๋.
ใด์๋ฌํ์ด์ง๋ฅผ ์ธ๋ถ์์ ์ ๊ทผ X
<%@ page errorPage="/error/viewErrorMessage.jsp"%>
<%@ page errorPage="/WEB-INF/jsp/viewErrorMessage.jsp"%>
p155 Chapter 07 ํ์ด์ง ๋ชจ๋ํ์ ์์ฒญ ํ๋ฆ ์ ์ด
jsp: ์ ๋์ฌ == JSP ์ก์ ํ๊ทธ
*** 1. jsp:include ์ก์ ํ๊ทธ -> ๋ชจ๋ํ
*** 2. include ์ง์์ -> ๋ชจ๋ํ
3. jsp:forward ์ก์ ํ๊ทธ
4. ๊ธฐ๋ณธ ๊ฐ์ฒด๋ฅผ ์ด์ฉํ ๊ฐ ์ ๋ฌ
[ ํ์ด์ง ๋ชจ๋ํ ]
์น ์ฌ์ดํธ์ ๋ชจ๋ ํ์ด์ง์ ๊ณตํต๋ถ๋ถ -> ๋ชจ๋ํ ( jsp )
( ์๋จ ๋ถ๋ถ, ์ผ์ชฝ๋ฉ๋ด๋ถ๋ถ, ํ๋จ๋ถ๋ถ )
์ฝ๋ ์ค๋ณต ์ ๊ฑฐ X, ์ ์ง ๋ณด์ ์ฉ์ด
jsp:include ์ก์ ํ๊ทธ๋ฅผ ์ฌ์ฉํด์ ๋ชจ๋ํํ JSP ํ์ด์ง๋ฅผ ํฌํจ์ํจ๋ค.
์ค์) main.jsp
์ฒ๋ฆฌ A
์ถ๋ ฅ๋ฒํผ (A+B+C)
jsp:include sub.jsp -> ์์ฒญ ์ด๋ sub.jsp B
์ฒ๋ฆฌ C
* sub.jsp include ์ก์ ํ๊ทธ ์ํด์ ์์ฒญ ํ๋ฆ์ด sub.jsp ํฌ์๋ฉ๋๋ ๊ฒ์ฒ๋ผ / ์ด์ ๊น์ง๋ ์ถ๋ ฅ๋ฒํผ์ ์ ์ฅ๋์ด์๋ ์ํ
* ์ถ๋ ฅ๋ฒํผ์ ๋ชจ๋์ด ์ถ๊ฐ
* ์์ฒญํ๋ฆ์ด ๋ฐ๋๋ค๋ ๊ฒ์ด ํฌ์ธํธ์!
์)
1) ๊ณตํต ๋ถ๋ถ์ ๋ชจ๋ํ top.jsp, left.jsp, bottom.jsp
webapp/layout/ top.jsp, bottom.jsp ๋ชจ๋ ํ์ด์ง์ ๊ณตํต๋ถ๋ถ
webapp/days05/layout/ left.jsp, top.jsp ๋ชจ๋ ํ์ด์ง์ ๊ณตํต๋ถ๋ถ
ex03_template.jsp
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%!
// jsp:include top.jsp ์ธ์ํ ์ ์๋ค.
// ์ ? ์ฒ๋ฆฌ ๊ณผ์ ์ดํด ๊ทธ๋ฆผ7.1 ( p 156 )
String id="admin";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 8. ์ค์ 11:53:14</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex03_template.jsp</h3>
<h3>ex03_template.jsp?msg=hello</h3>
<div style="text-align: center">
<table width="600" border="1" align="center">
<tr>
<td colspan="3">
<!-- top ๋ถ๋ถ -->
<jsp:include page="/layout/top.jsp" flush="false"></jsp:include>
</td>
</tr>
<tr height="300">
<td width="150" valign="top" style="background: yellow">
<!-- left ๋ถ๋ถ -->
<jsp:include page="/days05/layout/left.jsp" flush="false"></jsp:include>
</td>
<td>
<a href="ex03_memberAdd.jsp">ํ์ ์ถ๊ฐ</a><br>
ํ์ ๊ด๋ฆฌ Content ๋ถ๋ถ<br>
ํ์ ๊ด๋ฆฌ Content ๋ถ๋ถ<br>
ํ์ ๊ด๋ฆฌ Content ๋ถ๋ถ<br>
ํ์ ๊ด๋ฆฌ Content ๋ถ๋ถ<br>
ํ์ ๊ด๋ฆฌ Content ๋ถ๋ถ<br>
</td>
<td valign="top" style="background: red">
<!-- right ๋ถ๋ถ -->
<jsp:include page="/days05/layout/right.jsp" flush="false"></jsp:include>
</td>
</tr>
<tr>
<td colspan="3">
<!-- bottom ๋ถ๋ถ -->
<!--
ex03_template.jsp -> bottom.jsp ์์ฒญ ํ๋ฆ
ํ๋ผ๋ฏธํฐ ๊ฐ์ ์ ๋ฌํ๊ณ ์ถ๋ค.
-->
<jsp:include page="/layout/bottom.jsp" flush="false">
<jsp:param value="hi~~~" name="msg"/>
</jsp:include>
</td>
</tr>
</table>
*flush ์์ฑ : ์๋ต๋ฒํผ์ ๋ฃ๊ณ ์ ์ก์ํฌ๊ฑด์ง? false
*top bottom (style css) -> main์์ ์ฃผ๋ฉด๋จ,
* js -> ์ด๋์์ด๋ ์๊ด์์
-left-
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<ul>
<li>๋ก๊ทธ์ธ</li>
<li>ํ์๊ด๋ฆฌ</li>
<li>์ผ์ ๊ด๋ฆฌ</li>
<li>๋์๋ง</li>
</ul>
-right-
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
๊ด๊ณ 1<br>
๊ด๊ณ 2<br>
๊ด๊ณ 3<br>
๊ด๊ณ 4<br>
*template ์์ฒญํ ๋ ๋๊ฒจ์ ์ค๋ ํ๋ผ๋ฏธํฐ๊ฐ์ bottom ์์ ๋์ฐ๊ณ ์ถ์๋ (์ฟผ๋ฆฌ๋ฌธ์ผ๋ก)
-> bottom.jsp ์ String msg = erquest.getParameter("msg")
* ๋ง์ฝ ์์ฒญํ๋๋ฐ ํ๋ผ๋ฏธํฐ ๊ฐ์ bottom์ ํ๋ผ๋ฏธํฐ ๊ฐ์ ์ ๋ฌํ๊ณ ์ถ์ ๋
template์์ jsp:param
<jsp:include page="/layout/bottom.jsp" flush="false">
<jsp:param value="hi~~~" name="msg"/>
* mainํ์ด์ง์ ์ ์ญ๋ณ์ ์ ์ธํด๋ ๋ณ๊ฐ์ ์์ฒญํ๋ฆ์ผ๋ก ๊ฐ๊ธฐ ๋๋ฌธ์ bottom์์ ์ธ์ํ์ง ๋ชปํจ -> param์ผ๋ก ๋๊ฒจ์ค์ผํจ!
p 168 [ include ์ง์์๋ฅผ ์ด์ฉํ ์ค๋ณต๋ ์ฝ๋ ์ฝ์ ]
%@ page
%@ taglib
%@ include
// [WEB-INF/inc/include.jspf ]
// ์ฌ๋ฌ ํ์ด์ง์ ์ค๋ณต๋ ์๋ ์ฝ๋ฉ์ด ์ถ๊ฐ.. %@ include ์ง์์ .. ์ฌ์ฉ.
request.setCharacterEncoding("UTF-8");
String contextPath = request.getContextPath();
-> WEB-INF/inc ํด๋ ๋ง๋ค์ด์ ์ฌ๊ธฐ ๋ฃ์ (์ธ๋ถ ์ ๊ทผ ๋ถ๊ฐํ๋๋ก)
-include.jspf-
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
// [WEB-INF/inc/include.jspf ]
// ์ฌ๋ฌ ํ์ด์ง์ ์ค๋ณต๋ ์๋ ์ฝ๋ฉ์ด ์ถ๊ฐ.. %@ include ์ง์์ .. ์ฌ์ฉ.
request.setCharacterEncoding("UTF-8");
String contextPath = request.getContextPath();
String name ="admin";
%>
-jsp-
<%@ include file="/WEB-INF/inc/include.jspf" %>
[์ง๋ฌธ] ๊ฐ์ฌ๋ ๋จ์ํ ์ค๋ณต์ ๋ฌธ์ ๋ฉด ํ ํ๋ฆฟ์ ์ฌ์ฉํด๋ ๋์ง์๋์?
include ์ง์์ - bottom.jsp ๊ณตํต ๋ชจ๋ํ ์ถ๊ฐ, ๊ณตํต ์ค๋ณต ์ฝ๋ฉ
jsp:include ์ก์ ํ๊ทธ - bottom.jsp ๊ณตํต ๋ชจ๋ํ ์ถ๊ฐ, ๊ณตํต ์ค๋ณต ์ฝ๋ฉ
[ ์ฒ๋ฆฌ ๊ณผ์ ์ฐจ์ด์ ์ดํด ]
p 169 include ์ง์์ ์ฒ๋ฆฌ ๊ณผ์ [๊ทธ๋ฆผ 7.11]
include ์ง์์ - ๊ณตํต์ฝ๋ฉ์ด ์ปดํ์ผ๋์ด์ง๋ ํฌํจ๋๋ ์ (์๋ธ๋ฆฟ ๊ฐ์ฒด ํ๋)
jsp:include ์ก์ ํ๊ทธ - ์๋ต๋ฒํผ ๋ด๊ณ ์๋ก์ด์์ฒญ ์ผ์ด๋ ํ ๋ค์ ์๋ธ๋ฆฟ ๊ฐ์ฒด๊ฐ ์๋ต (์๋ธ๋ฆฟ ๊ฐ์ฒด ๋๊ฐ , ํ๋ฆ ๋ฌ๋ผ์ง)
p 173 ์ฝ๋ ์กฐ๊ฐ ์๋ ํฌํจ ๊ธฐ๋ฅ
1) ๊ณตํต์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ณ์ ์ง์
@ include file="/common/variable.jspf"
2) ์ ์๊ถ - ๊ฐ๋จํ ๋ฌธ์ฅ.
@ include file="/common/footer.jspf"
๋ชจ๋ ํ์ด์ง์ ์์ ์ฝ๋ฉ์ ํ ํ์์์ด web.xml
<jsp-config>
<jsp-property-group>
<url-pattern>/days05/*</url-pattern>
<include-prelude>/common/variable.jspf</include-prelude>
<include-coda>/common/footer.jspf</include-coda>
</jsp-property-group>
</jsp-config>
p 177 include ์ก์ ํ๊ทธ์ include ์ง์์์ ์ฐจ์ด์ (๋น๊ต )
p 177 jsp:forwrd ์ก์ ํ๊ทธ X
p 190 Chapter 08 ์๋ฐ๋น๊ณผ jsp:useBean ์ก์ ํ๊ทธ
1. ์๋ฐ๋น(bean) == ์๋น์ฆ(javabeans) ?
JSP ๊ธฐ๋ฐ + ์น ์ดํ๋ฆฌ์ผ์ด์ ์์
[์ ๋ณด]๋ฅผ ํํ(์ ์ฅ)ํ๋ [๊ฐ์ฒด] == DTO(์ ๋ณด๊ฐ์ง๊ณ ์ ๋ฌ) == VO(์ ๋ณด)
Spring ๊ธฐ๋ฐ POJO
2. ์๋ฐ๋น(bean) ๊ท์ฝ / ์๋ธ๋ฆฟ ๊ท์ฝ p,hs, doget,dopost,service ์ค๋ฒ๋ผ์ด๋ฉ.
1) private ํ๋ ์ ์ธ
2) getter, setter ์ ์ธ
3) ์ง๋ ฌํ๊ฐ ๊ฐ๋ฅํ ํด๋์ค ์ ์ธ
*์ง๋ ฌํ :
3. ์๋ฐ๋น์ ์์ฑ, ๋ณ๊ฒฝ ์ด๋ฒคํธ, ๊ฐ์ฒด ์ง๋ ฌํ๋ฅผ ์ํ ํ์ค์ด๋ค.
์) days05.MemberInfo.java ์๋ฐ๋น ์ ์ธ
package days05;
import java.io.Serializable;
import java.util.Date;
// JSP ๊ธฐ๋ฐ ์น ์ดํ๋ฆฌ์ผ์ด์
์์ ํ์์ ๋ณด๋ฅผ ์ ์ฅํ ๊ฐ์ฒด - ์๋ฐ๋น ์ ์ธ
public class MemberInfo implements Serializable{
private static final long serialVersionUID = 2490129593045133574L;
// ํ๋ private
private String id;
private String passwd;
private String name;
private Date registerDate;
private String email;
// getter, setter
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPasswd() {
return passwd;
}
public void setPasswd(String passwd) {
this.passwd = passwd;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getRegisterDate() {
return registerDate;
}
public void setRegisterDate(Date registerDate) {
this.registerDate = registerDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
} // class
ex04_02.jsp ์ถ๊ฐ.
<form action="ex04_05.jsp" method="get">
<table border="1" style="width:400px">
<tr>
<td>์์ด๋</td>
<td><input type="text" name="id" value="admin"></td>
</tr>
<tr>
<td>์ด๋ฆ</td>
<td><input type="text" name="name" value="๊ด๋ฆฌ์"></td>
</tr>
<tr>
<td>๋น๋ฐ๋ฒํธ</td>
<td><input type="password" name="passwd" value="1234"></td>
</tr>
<tr>
<td>์ด๋ฉ์ผ</td>
<td><input type="text" name="email" value="admin@naver.com"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit">
<input type="reset">
</td>
</tr>
</table>
</form>
03.jsp
<%@page import="days05.MemberInfo"%>
<%@page import="java.util.Date"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!--
http://localhost/jspPro/days05/ex04_03.jsp
?
id=admin
&
name=%EA%B4%80%EB%A6%AC%EC%9E%90
&
passwd=1234
&
email=admin%40naver.com
-->
<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String passwd = request.getParameter("passwd");
String email = request.getParameter("email");
Date registerDate = new Date(); // ์ค๋๋ ์ง๋ฅผ ๊ฐ์
์ผ๋ก ์ค์ .
// ์๋ฐ๋น( = JSP ์ ๋ณด ์ ์ฅํ๋ ๊ฐ์ฒด ) ์์ฑ
MemberInfo mi = new MemberInfo();
mi.setId(id);
mi.setName(name);
mi.setPasswd(passwd);
mi.setRegisterDate(registerDate);
mi.setEmail(email);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 8. ์คํ 2:21:05</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex04_03.jsp - MemberInfo ์ ๋ณด ์ถ๋ ฅ </h3>
์์ด๋ : <%= mi.getId() %><br>
์ด๋ฆ : <%= mi.getName() %><br>
๋น๋ฐ๋ฒํธ : <%= mi.getPasswd() %><br>
๋ฑ๋ก์ผ : <%= mi.getRegisterDate() %><br>
์ด๋ฉ์ผ : <%= mi.getEmail() %><br>
04.jsp
<%@page import="days05.MemberInfo"%>
<%@page import="java.util.Date"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String id = request.getParameter("id");
String name = request.getParameter("name");
String passwd = request.getParameter("passwd");
String email = request.getParameter("email");
Date registerDate = new Date(); // ์ค๋๋ ์ง๋ฅผ ๊ฐ์
์ผ๋ก ์ค์ .
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 8. ์คํ 2:28:17</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex04_04.jsp - MemberInfo ์ ๋ณด ์ถ๋ ฅ </h3>
<pre>
// ์๋ฐ๋น( = JSP ์ ๋ณด ์ ์ฅํ๋ ๊ฐ์ฒด ) ์์ฑ
MemberInfo mi = new MemberInfo();
mi.setId(id);
mi.setName(name);
mi.setPasswd(passwd);
mi.setRegisterDate(registerDate);
mi.setEmail(email);
์์ ์ฝ๋ฉ์ jsp:useBean ์ก์
ํ๊ทธ๋ก ์์ .....
</pre>
<jsp:useBean id="mi" class="days05.MemberInfo"></jsp:useBean>
<!-- Spring -->
<jsp:setProperty property="id" name="mi" value="<%= id %>"/>
<jsp:setProperty property="name" name="mi" value="<%= name %>"/>
<jsp:setProperty property="passwd" name="mi" value="<%= passwd %>"/>
<jsp:setProperty property="registerDate" name="mi" value="<%= registerDate %>"/>
<jsp:setProperty property="email" name="mi" value="<%= email %>"/>
์์ด๋ : <%= mi.getId() %><br>
์ด๋ฆ : <%= mi.getName() %><br>
๋น๋ฐ๋ฒํธ : <%= mi.getPasswd() %><br>
๋ฑ๋ก์ผ : <%= mi.getRegisterDate() %><br>
์ด๋ฉ์ผ : <%= mi.getEmail() %><br>
05.jsp
<%@page import="days05.MemberInfo"%>
<%@page import="java.util.Date"%>
<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
Date registerDate = new Date(); // ์ค๋๋ ์ง๋ฅผ ๊ฐ์
์ผ๋ก ์ค์ .
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2022. 12. 8. ์คํ 2:28:17</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/SiSt.ico">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<style>
</style>
</head>
<body>
<h3>ex04_05.jsp - MemberInfo ์ ๋ณด ์ถ๋ ฅ </h3>
<pre>
1. ํ๋๋ช
== name ์์ฑ ( ์กฐ๊ฑด )
2. ์ต๊ด์ ์ผ๋ก..
ใฑ.
scott.dept / deptno, dname, loc
ใด.
DeptDTO
private int deptno;
setter, geter
ใท.
์
๋ ฅํผ
์
๋ ฅํ๊ทธ name ="deptno"
</pre>
<jsp:useBean id="mi" class="days05.MemberInfo"></jsp:useBean>
<jsp:setProperty property="*" name="mi"/>
<jsp:setProperty property="registerDate" name="mi" value="<%= registerDate %>"/>
์์ด๋ : <%= mi.getId() %><br>
์ด๋ฆ : <%= mi.getName() %><br>
๋น๋ฐ๋ฒํธ : <%= mi.getPasswd() %><br>
๋ฑ๋ก์ผ : <%= mi.getRegisterDate() %><br>
์ด๋ฉ์ผ : <%= mi.getEmail() %><br>
[ ๊ผญ ์งํฌ ๊ฒ ]
์๋ฐ๋น์ ํ๋๋ช ๊ณผ ๋ฐ๋์ ๋์ผํ name ์์ฑ์ ์ค์ ํ๋ค.
->ํธ๋ฆฌํ์ : ์ด๋ฆ ๋๊ฐ๊ธฐ ๋๋ฌธ์ ํ๋ผ๋ฏธํฐ ๋ฐ์ ํ์์์ (05์์ ์ฒ๋ผ ํ๋ฒ์ ๋ฐ์์ฌ์์๋ค) - register date ๋นผ๊ณ
์ต๊ทผ๋๊ธ