[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 νŽ˜μ΄μ§€λ₯Ό ν¬ν•¨μ‹œν‚¨λ‹€. 

 

     

p 156 κ·Έλ¦Ό &nbsp;&nbsp; 7.1 &nbsp; &nbsp;&nbsp; - 이해.

        μ€‘μš”)  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 λΉΌκ³ 

 

  • 넀이버 λΈ”λŸ¬κ·Έ κ³΅μœ ν•˜κΈ°
  • 넀이버 λ°΄λ“œμ— κ³΅μœ ν•˜κΈ°
  • 페이슀뢁 κ³΅μœ ν•˜κΈ°
  • μΉ΄μΉ΄μ˜€μŠ€ν† λ¦¬ κ³΅μœ ν•˜κΈ°