Notice
Recent Posts
Recent Comments
ยซ   2024/12   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
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
Archives
Today
In Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

A Joyful AI Research Journey๐ŸŒณ๐Ÿ˜Š

[58] 230322 JSP Ch. 8 ์ž๋ฐ”๋นˆ๊ณผ ์•ก์…˜ ํƒœ๊ทธ, Ch. 9 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 1 : ์ฟ ํ‚ค, Ch. 10 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 2 : ์„ธ์…˜ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 58์ผ] ๋ณธ๋ฌธ

๐ŸŒณBootcamp Revision 2023โœจ/HTML5, CSS3, JSP

[58] 230322 JSP Ch. 8 ์ž๋ฐ”๋นˆ๊ณผ ์•ก์…˜ ํƒœ๊ทธ, Ch. 9 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 1 : ์ฟ ํ‚ค, Ch. 10 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 2 : ์„ธ์…˜ [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 58์ผ]

yjyuwisely 2023. 3. 22. 09:53

230322 Wed 58th class

Ch. 8 ์ž๋ฐ”๋นˆ๊ณผ ์•ก์…˜ ํƒœ๊ทธ
Ch. 9 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 1 : ์ฟ ํ‚ค
Ch. 10 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 2 : ์„ธ์…˜

์ง„๋„: p. 191 ~ (๊ต์žฌ: ์ตœ๋ฒ”๊ท ์˜ JSP 2.3 ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ: ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์ค‘๊ธ‰๊นŒ์ง€, ์ €์ž: ์ตœ๋ฒ”๊ท )
์ฑ… ์˜ˆ์ œ ์ฝ”๋“œ: https://github.com/madvirus/jsp23
์ €์ž ๋ธ”๋กœ๊ทธ: https://javacan.tistory.com/

 

์ตœ๋ฒ”๊ท ์˜ JSP 2.3 ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ: ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์ค‘๊ธ‰๊นŒ์ง€ | ์ตœ๋ฒ”๊ท  - ๊ต๋ณด๋ฌธ๊ณ 

์ตœ๋ฒ”๊ท ์˜ JSP 2.3 ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ: ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์ค‘๊ธ‰๊นŒ์ง€ | [์ตœ๋ฒ”๊ท ์˜ JSP 2.3 ์›น ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์ค‘๊ธ‰๊นŒ์ง€]๋Š” JSP 2.3์˜ ์ƒˆ๋กœ์šด ํŠน์ง• ๋ฐ˜์˜๊ณผ JSP๋ฅผ ์ง€์›ํ•˜๋Š” ์š”์†Œ์ธ ์„œ๋ธ”๋ฆฟ๊ณผ ํ‘œํ˜„ ์–ธ์–ด ๋“ฑ์˜ ์ƒˆ๋กœ์šด

product.kyobobook.co.kr


์˜ค๋Š˜ ๋ฐฐ์šด ๊ฒƒ ์ค‘ ๊ธฐ์–ตํ•  ๊ฒƒ์„ ์ •๋ฆฌํ–ˆ๋‹ค.


์ž๋ฐ” ๋ฐฐ์› ๋˜ ๊ฒƒ ๋˜๋Œ์•„๋ณด๊ธฐ 

ํด๋ž˜์Šค๋ฅผ ์„ ์–ธํ•  ๋•Œ ๊ฐ€๋Šฅํ•˜๋‹ค๋ฉด ํ•„๋“œ๋ฅผ private์œผ๋กœ ์„ ์–ธํ•ด์„œ ์™ธ๋ถ€๋กœ๋ถ€ํ„ฐ ๋ณดํ˜ธํ•˜๊ณ , ํ•„๋“œ์— ๋Œ€ํ•œ Setter์™€ Getter ๋ฉ”์„œ๋“œ๋ฅผ ์ž‘์„ฑํ•ด์„œ ํ•„๋“œ๊ฐ’์„ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณ€๊ฒฝ/์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ์ข‹๋‹ค.

set์ €์žฅํ•œ๋‹ค.
get: ์ €์žฅ๋œ ๊ฑฐ ๊ฐ€์ ธ์˜จ๋‹ค.

 
SET์€ ๋ณ€์ˆซ๊ฐ’์„ ํ• ๋‹นํ•˜๋Š” ๋ชฉ์ ์˜ ํ•จ์ˆ˜์ด๊ธฐ ๋•Œ๋ฌธ์— ์ธ์ž๋ฅผ ๋ฐ›์•„์•ผ ํ•˜๊ณ 
GET์€ ๋ณ€์ˆ˜๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ชฉ์ ์ด๊ธฐ ๋•Œ๋ฌธ์— return์ด ํ•„์š”ํ•˜๋‹ค.

Setter: ์™ธ๋ถ€์—์„œ ๊ฐ’์„ ๋ฐ›์•„ ํ•„๋“œ๋ฅผ ๋ณ€๊ฒฝํ•˜๋Š” ๋ฉ”์„œ๋“œ์ด๋‹ค. 
Getter: 
ํ•„๋“œ์˜ ๊ฐ’์„ ์™ธ๋ถ€๋กœ ๋ฆฌํ„ดํ•ด์ฃผ๋Š” ๋ฉ”์„œ๋“œ์ด๋‹ค. ๋ฉ”์„œ๋“œ๋กœ ํ•„๋“œ๊ฐ’์„ ๊ฐ€๊ณตํ•œ ํ›„ ์™ธ๋ถ€๋กœ ์ „๋‹ฌํ•œ๋‹ค.

2023.02.14 - [๐ŸŒณK-Digital Revision 2023โœจ/Java] - [33] 230214 Java Ch. 6 ํด๋ž˜์Šค: 6. ํŒจํ‚ค์ง€์™€ ์ ‘๊ทผ ์ œํ•œ์ž [K-๋””์ง€ํ„ธ ํŠธ๋ ˆ์ด๋‹ 33์ผ]


Class URLEncoder

public class URLEncoder
extends Object
Utility class for HTML form encoding. This class contains static methods for converting a String to the application/x-www-form-urlencoded MIME format. For more information about HTML form encoding, consult the HTML specification.

https://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html


Ch. 8 ์ž๋ฐ”๋นˆ๊ณผ ์•ก์…˜ ํƒœ๊ทธ

์ฑ…์˜ ๋ชฉ์ฐจ
01 ์ž๋ฐ”๋นˆ(JavaBeans)
1.1 ์ž๋ฐ”๋นˆ ํ”„๋กœํผํ‹ฐ

02 ์˜ˆ์ œ์—์„œ ์‚ฌ์šฉํ•  ์ž๋ฐ”๋นˆ ํด๋ž˜์Šค

03 ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•œ ์ž๋ฐ” ๊ฐ์ฒด ์‚ฌ์šฉ
3.1 <jsp:useBean> ์•ก์…˜ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด ์ƒ์„ฑํ•˜๊ธฐ
3.2 <jsp:setProperty> ์•ก์…˜ ํƒœ๊ทธ์™€ <jsp:getProperty> ์•ก์…˜ ํƒœ๊ทธ
3.3 ์ž๋ฐ”๋นˆ ํ”„๋กœํผํ‹ฐ ํƒ€์ž…์— ๋”ฐ๋ฅธ ๊ฐ’ ๋งคํ•‘ 


JSP ๊ธฐ๋ฐ˜ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ •๋ณด๋ฅผ ํ‘œํ˜„ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ์ค‘ ํ•˜๋‚˜๊ฐ€ ์ž๋ฐ”๋นˆ(JavaBeans)์ด๋‹ค. 

ex) ํšŒ์› ์ •๋ณด, ๊ฒŒ์‹œํŒ ๊ธ€์˜ ์ •๋ณด๋ฅผ ์ถœ๋ ฅํ•  ๋•Œ, ์ •๋ณด๋ฅผ ์ €์žฅํ•˜๊ณ  ์žˆ๋Š” ์ž๋ฐ”๋นˆ ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•˜๊ฒŒ ๋œ๋‹ค.
์ž๋ฐ”๋นˆ์ด ๋ฌด์—‡์ธ์ง€ ์‚ดํŽด๋ณด๊ณ , JSP ํŽ˜์ด์ง€์—์„œ ์ž๋ฐ”๋นˆ์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋„๋ก ๋„์™€์ฃผ๋Š” ์•ก์…˜ ํƒœ๊ทธ์— ๋Œ€ํ•ด ์‚ดํŽด๋ณธ๋‹ค.

์ฐธ๊ณ : https://choitaetae.tistory.com/96


8.1 ์ž๋ฐ”๋นˆ(JavaBeans) p. 191

์ž๋ฐ”๋นˆ์€ ์†์„ฑ(๋ฐ์ดํ„ฐ), ๋ณ€๊ฒฝ ์ด๋ฒคํŠธ, ๊ฐ์ฒด ์ง๋ ฌํ™”๋ฅผ ์œ„ํ•œ ํ‘œ์ค€์ด๋‹ค. ์ด ์ค‘์—์„œ JSP์—์„œ๋Š” ์†์„ฑ์„ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•œ ์šฉ๋„๋กœ ์‚ฌ์šฉ๋œ๋‹ค.

๊ฐ์ฒด ์ง๋ ฌํ™”(Serialization): ๊ฐ์ฒด๋ฅผ ์ง๋ ฌํ™”ํ•˜์—ฌ ์ „์†ก ๊ฐ€๋Šฅํ•œ ํ˜•ํƒœ๋กœ ๋งŒ๋“œ๋Š” ๊ฒƒ

์ž๋ฐ”๋นˆ ๊ทœ์•ฝ์„ ๋”ฐ๋ฅด๋Š” ํด๋ž˜์Šค๋ฅผ ์ž๋ฐ”๋นˆ์ด๋ผ๊ณ  ๋ถ€๋ฅธ๋‹ค. 
JSP ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ ์‚ฌ์šฉํ•˜๋Š” ์ž๋ฐ”๋นˆ ํด๋ž˜์Šค๋Š” ์•„๋ž˜ ์ฝ”๋“œ์ฒ˜๋Ÿผ
[1] ๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ํ•„๋“œ
[2] ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์–ด์˜ฌ ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์„œ๋“œ
[3] ๊ฐ’์„ ์ €์žฅํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๋ฉ”์„œ๋“œ๋กœ ๊ตฌ์„ฑ๋œ๋‹ค. 

์ž๋ฐ”๋นˆ ๊ทœ์•ฝ์„ ๋”ฐ๋ฅด๋Š” ํด๋ž˜์Šค์˜ ๊ตฌ์กฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

public class BeanClassName implements java.io.Serializable{
    /*[1] ๊ฐ’์„ ์ €์žฅํ•˜๋Š” ํ•„๋“œ */ 
    private String value;
    
    /* BeanClassName์˜ ๊ธฐ๋ณธ ์ƒ์„ฑ์ž */
    public BeanClassName(){
    }
    
    /*[2] ํ•„๋“œ์˜ ๊ฐ’์„ ์ฝ์–ด์˜ค๋Š” ๊ฐ’ */
    public String getValue(){
    	return value;
        
    /*[3] ํ•„๋“œ์˜ ๊ฐ’์„ ๋ณ€๊ฒฝํ•˜๋Š” ๊ฐ’ */
    public void setValue(String value){
        this.value = value;
    }
}

1) ์ž๋ฐ”๋นˆ ํ”„๋กœํผํ‹ฐ

ํ”„๋กœํผํ‹ฐ๋Š” ์ž๋ฐ”๋นˆ์— ์ €์žฅ๋˜๋Š” ๊ฐ’์„ ๋‚˜ํƒ€๋‚ธ๋‹ค.


8.2 ์˜ˆ์ œ์—์„œ ์‚ฌ์šฉํ•  ์ž๋ฐ”๋นˆ ํด๋ž˜์Šค p. 193

์ดํด๋ฆฝ์Šค์—์„œ ์ž๋ฐ” ํŒŒ์ผ์€ Java Resources - src์— ์ €์žฅํ•œ๋‹ค.

์ฑ…์˜ ์˜ˆ์ œ์ฒ˜๋Ÿผ chap08.member ํŒจํ‚ค์ง€ ๋‚ด์˜ Memberinfo ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ ๋‹ค.

Source - Generate Getters and Setters์„ ์ด์šฉํ•ด์„œ ์ž๋™ ์™„์„ฑ ๊ธฐ๋Šฅ์„ ์‚ฌ์šฉํ•œ๋‹ค.

Public์œผ๋กœ ์„ค์ •ํ•œ๋‹ค.

์ž๋™์™„์„ฑ์œผ๋กœ ์•„๋ž˜์˜ public ์ฝ”๋“œ๊ฐ€ ๋งŒ๋“ค์–ด์กŒ๋‹ค.

์˜ˆ์ œ 8-1) MemberInfo ์ž๋ฐ”๋นˆ ํด๋ž˜์Šค์˜ ์†Œ์Šค ์ฝ”๋“œ MemberInfo.java

package chap08.member; //ํŒจํ‚ค์ง€

import java.util.Date;

public class MemberInfo { //ํด๋ž˜์Šค
	//private: ์ง์ ‘์  ์ ‘๊ทผ ํ—ˆ์šฉX
	private String id;
	private String password;
	private String name;
	private Date registerDate; //Date: ํด๋ž˜์Šค์˜ ํž˜์„ ๋นŒ๋ ค์„œ ํด๋ž˜์Šค ํƒ€์ž…์œผ๋กœ ์ €์žฅ
	private String email;
	public String getId() {
		return id;
	}
	public void setId(String id) { //makeObject.jsp์˜ "madvirus"
		this.id = id;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) { //makeObject.jsp์˜ "์ตœ๋ฒ”๊ท " 
		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;
	}
}

8.3 ํƒœ๊ทธ๋ฅผ ์ด์šฉํ•œ ์ž๋ฐ” ๊ฐ์ฒด ์‚ฌ์šฉ


1) <jsp:useBean> ์•ก์…˜ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐ์ฒด ์ƒ์„ฑํ•˜๊ธฐ

 <jsp:useBean> ์•ก์…˜ ํƒœ๊ทธ๋Š” JSP ํŽ˜์ด์ง€์—์„œ ์‚ฌ์šฉํ•  ์ž๋ฐ”๋นˆ ๊ฐ์ฒด๋ฅผ ์ง€์ •ํ•  ๋•Œ ์‚ฌ์šฉํ•œ๋‹ค.
๊ธฐ๋ณธ ๊ตฌ๋ฌธ์€ ์•„๋ž˜์™€ ๊ฐ™๋‹ค.

<jsp:useBean id="[๋นˆ์ด๋ฆ„]" class="[์ž๋ฐ”๋นˆํด๋ž˜์Šค์ด๋ฆ„]" scope="[๋ฒ”์œ„]" />

์˜ˆ์ œ 8-2) makeObject.jsp
<jsp:useBean> ์•ก์…˜ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ MemberInfo ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•œ ํ›„ <jsp:forward>๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‹ค๋ฅธ ํŽ˜์ด์ง€๋กœ ํ๋ฆ„์„ ์ด๋™์‹œํ‚จ๋‹ค.
MemberInfo member = new MemberInfo(); (์—ฌ๊ธฐ์„œ member๋Š” jsp:useBean id="member"์˜ member)

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" scope="request" class="chap08.member.MemberInfo" /> 
<!-- id ๊ฐ’์€ ์ฃผ๊ณ  ์‹ถ์€ ๋ฐ๋กœ ์ฃผ๋ฉด ๋œ๋‹ค. ์—ฌ๊ธฐ์„  "member"๋กœ ํ–ˆ๋‹ค. class๋Š” ์•ž์˜ java ํŒŒ์ผ์˜ 01~11ํ–‰์ด๋‹ค. (public ์•ž๊นŒ์ง€)-->

<% //์ž๋ฐ”์˜ MemberInfo์˜ setId, setName์„ ํ˜ธ์ถœํ•จ 
	//๋ฉ”์ธ ๋ฉ”์„œ๋“œ
	member.setId("madvirus"); //member๋Š” ์œ„ ์ฝ”๋“œ์˜ jsp:useBean id="member"์˜ member์ด๋‹ค. 
	member.setName("์ตœ๋ฒ”๊ท ");
%>
<jsp:forward page="/useObject.jsp" /> <!-- jsp:forward: ํŽ˜์ด์ง€ ์ด๋™, ์ฆ‰ useObject.jsp๋กœ ์ด๋™ํ•œ๋‹ค. -->

๊ฒฐ๊ณผ)


makeObject.jsp๋ฅผ ์‹คํ–‰ํ•˜๋ฉด MembershipInfo์˜ ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•ด์„œ request ๊ธฐ๋ณธ ๊ฐ์ฒด์˜ "member" ์†์„ฑ์— ์ €์žฅํ•œ ํ›„ useOjbect.jsp๋กœ ํฌ์›Œ๋”ฉ(๋‹ค๋ฅธ ํŽ˜์ด์ง€๋กœ ์ „ํ™˜ํ•˜๋Š” ๋ฐฉ์‹)ํ•œ๋‹ค. 

์˜ˆ์ œ 8-3) <jsp:useBean> ์•ก์…˜ ํƒœ๊ทธ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ makeObject.jsp๊ฐ€ ์ƒ์„ฑํ•œ ๊ฐ์ฒด๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค. useObject.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<jsp:useBean id="member" scope="request"
             class="chap08.member.MemberInfo" />
<html>
<head><title>์ธ์‚ฌ๋ง</title></head>
<body>

<!-- ์ž๋ฐ” ๋ฉ”์„œ๋“œ ํ˜ธ์ถœ -->
<%= member.getName() %> (<%= member.getId() %>) ํšŒ์›๋‹˜
์•ˆ๋…•ํ•˜์„ธ์š”.

</body>
</html>

๊ฒฐ๊ณผ)

์ˆ˜์—…์˜ ์„ค๋ช… :)


2) <jsp:setProperty> ์•ก์…˜ ํƒœ๊ทธ์™€ <jsp:getProperty> ์•ก์…˜ ํƒœ๊ทธ p. 199

์˜ˆ์ œ 8-4) ํšŒ์›๊ฐ€์ž… ์–‘์‹์„ ๋ณด์—ฌ์ฃผ๋Š” JSP ํŽ˜์ด์ง€ membershipForm.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><title>ํšŒ์›๊ฐ€์ž… ์ž…๋ ฅ ํผ</title></head>
<body>
<form action="processJoining.jsp" method="post">
<table border="1">
<tr>
	<td>์•„์ด๋””</td>
	<td colspan="3"><input type="text" name="id" size="10"></td>
</tr>
<tr>
	<td>์ด๋ฆ„</td>
	<td><input type="text" name="name" size="10"></td>
	<td>์ด๋ฉ”์ผ</td>
	<td><input type="text" name="email" size="10"></td>
</tr>
<tr>
	<td colspan="4" align="center">
	<input type="submit" value="ํšŒ์›๊ฐ€์ž…">
	</td>
</tr>
</table>
</form>
</body>
</html>

๊ฒฐ๊ณผ)

์ž…๋ ฅ ํผ์ด ์ถœ๋ ฅ๋œ๋‹ค.


ํšŒ์›๊ฐ€์ž… ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅด๋ฉด ์ž…๋ ฅํ•œ ๋ฐ์ดํ„ฐ๋ฅผ POST ๋ฐฉ์‹์œผ๋กœ processJoining.jsp์— ์ „๋‹ฌํ•œ๋‹ค. 
์˜ˆ์ œ 8-5) ์ „๋‹ฌ ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ MemberInfo ์ž๋ฐ”๋นˆ ํด๋ž˜์Šค์˜ ๊ฐ์ฒด์— ์ €์žฅํ•ด์„œ ํ™”๋ฉด์— ์ถœ๋ ฅํ•ด์ค€๋‹ค. processJoining.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<jsp:useBean id="memberInfo" class="chap08.member.MemberInfo" />
<jsp:setProperty name="memberInfo" property="*" /> <!-- *: ๋ชจ๋‘ ์‚ฌ์šฉํ•œ๋‹ค. -->

<!-- ์•„๋ž˜๋Š” ๋‚˜๋‰œ ์ฝ”๋“œ -->
<!--<jsp:setProperty name="memberInfo" property="id" />
<jsp:setProperty name="memberInfo" property="password" />
<jsp:setProperty name="memberInfo" property="name" />
<jsp:setProperty name="memberInfo" property="email" /> -->

<jsp:setProperty name="memberInfo" property="password"
				 value="<%= memberInfo.getId() %>" />
<html>
<head><title>๊ฐ€์ž…</title></head>
<body>

<table border="1">
<tr>
	<td>์•„์ด๋””</td>
	<td><jsp:getProperty name="memberInfo" property="id" /></td>
	<td>์•”ํ˜ธ</td>
	<td><jsp:getProperty name="memberInfo" property="password" /></td>
</tr>
<tr>
<tr>
    <td>์ด๋ฆ„</td>
    <td><jsp:getProperty name="memberInfo" property="name" /></td>
    <td>์ด๋ฉ”์ผ</td>
    <td><jsp:getProperty name="memberInfo" property="email" /></td>
</tr>
</table>

</body>
</html>

๊ฒฐ๊ณผ)

์•„๋ž˜ ์ฝ”๋“œ ๋•Œ๋ฌธ์— ์•„์ด๋””์™€ ์•”ํ˜ธ๋Š” ๊ฐ™๊ฒŒ ๋‚˜์˜จ๋‹ค. 

<jsp:setProperty name="memberInfo" property="password"
				 value="<%= memberInfo.getId() %>" />

์˜ˆ์ œ 8-1) MemberInfo.java, 8-4) membershipForm.jsp, 8-5) processJoining.jsp์˜ id๊ฐ€ ๊ฐ™๋‹ค.


3) ์ž๋ฐ”๋นˆ ํ”„๋กœํผํ‹ฐ ํƒ€์ž…์— ๋”ฐ๋ฅธ ๊ฐ’ ๋งคํ•‘


Ch. 9 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 1 : ์ฟ ํ‚ค p. 205

์ฑ…์˜ ๋ชฉ์ฐจ
01 ์ฟ ํ‚ค ์‚ฌ์šฉํ•˜๊ธฐ

1.1 ์ฟ ํ‚ค์˜ ๊ตฌ์„ฑ
1.2 ์ฟ ํ‚ค ์ƒ์„ฑํ•˜๊ธฐ
1.3 ์ฟ ํ‚ค ๊ฐ’ ์ฝ์–ด์˜ค๊ธฐ
1.4 ์ฟ ํ‚ค ๊ฐ’ ๋ณ€๊ฒฝ ๋ฐ ์ฟ ํ‚ค ์‚ญ์ œํ•˜๊ธฐ
1.5 ์ฟ ํ‚ค์˜ ๋„๋ฉ”์ธ
1.6 ์ฟ ํ‚ค์˜ ๊ฒฝ๋กœ
1.7 ์ฟ ํ‚ค์˜ ์œ ํšจ์‹œ๊ฐ„
1.8 ์ฟ ํ‚ค์™€ ํ—ค๋”

02 ์ฟ ํ‚ค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํด๋ž˜์Šค
2.1 Cookies ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ ์ฟ ํ‚ค ์ƒ์„ฑ
2.2 Cookies ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ ์ฟ ํ‚ค ์ฝ๊ธฐ

03 ์ฟ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•œ ๋กœ๊ทธ์ธ ์ƒํƒœ ์œ ์ง€
3.1 ๋กœ๊ทธ์ธ ์ฒ˜๋ฆฌ
3.2 ๋กœ๊ทธ์ธ ์—ฌ๋ถ€ ํŒ๋‹จ
3.3 ๋กœ๊ทธ์•„์›ƒ ์ฒ˜๋ฆฌ

9.1 ์ฟ ํ‚ค ์‚ฌ์šฉํ•˜๊ธฐ p. 205

์ฟ ํ‚ค(cookie)๋Š” ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ๋ณด๊ด€ํ•˜๋Š” ๋ฐ์ดํ„ฐ์ด๋‹ค. ์›น ๋ธŒ๋ผ์šฐ์ €๋Š” ์›น ์„œ๋ฒ„์— ์š”์ฒญ์„ ๋ณด๋‚ผ ๋•Œ ์ฟ ํ‚ค๋ฅผ ํ•จ๊ป˜ ์ „์†กํ•˜๋ฉฐ, ์›น ์„œ๋ฒ„๋Š” ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์ „์†กํ•œ ์ฟ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํ•„์š”ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ์„ ์ˆ˜ ์žˆ๋‹ค.
์ฟ ํ‚ค๋Š” ์›น ์„œ๋ฒ„์™€ ์›น ๋ธŒ๋ผ์šฐ์ € ์–‘์ชฝ์—์„œ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋Š”๋ฐ, JSP์—์„œ ์ƒ์„ฑํ•˜๋Š” ์ฟ ํ‚ค๋Š” ์›น ์„œ๋ฒ„์—์„œ ์ƒ์„ฑํ•˜๋Š” ์ฟ ํ‚ค์ด๋‹ค.


1) ์ฟ ํ‚ค์˜ ๊ตฌ์„ฑ


2) ์ฟ ํ‚ค ์ƒ์„ฑํ•˜๊ธฐ

3) ์ฟ ํ‚ค ๊ฐ’ ์ฝ์–ด์˜ค๊ธฐ

4) ์ฟ ํ‚ค ๊ฐ’ ๋ณ€๊ฒฝ ๋ฐ ์ฟ ํ‚ค ์‚ญ์ œํ•˜๊ธฐ

5) ์ฟ ํ‚ค์˜ ๋„๋ฉ”์ธ

6) ์ฟ ํ‚ค์˜ ๊ฒฝ๋กœ

7) ์ฟ ํ‚ค์˜ ์œ ํšจ์‹œ๊ฐ„

8) ์ฟ ํ‚ค์™€ ํ—ค๋”


9.2 ์ฟ ํ‚ค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํด๋ž˜์Šค

1) Cookies ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ ์ฟ ํ‚ค ์ƒ์„ฑ p. 224

Cookies ํด๋ž˜์Šค๋Š” ์„ธ ๊ฐ€์ง€ createCookie() ๋ฉ”์„œ๋“œ๋ฅผ ์ œ๊ณตํ•˜๋ฉฐ ๋‹ค์Œ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.

Cookie cookie1 = Cookies.createCookie("name", "์ตœ๋ฒ”๊ท ")
Cookie cookie2 = Cookies.createCookie("name2", "์ตœ๋ฒ”๊ท ", "/path1", -1)
Cookie cookie3 = Cookies.createCookie("id", "jsp", ".madvirus.net", "/", 60);

2) Cookies ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•œ ์ฟ ํ‚ค ์ฝ๊ธฐ p. 221

package util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.Cookie;
import java.util.Map;
import java.net.URLEncoder; 
import java.net.URLDecoder; 
import java.io.IOException; 


public class Cookies {

	private Map<String, Cookie> cookieMap = 
			new java.util.HashMap<String, Cookie>();

	public Cookies(HttpServletRequest request) {
		Cookie[] cookies = request.getCookies();
		if (cookies != null) {
			for (int i = 0 ; i < cookies.length ; i++) {
				cookieMap.put(cookies[i].getName(), cookies[i]);
			}
		}
	}

	public Cookie getCookie(String name) {
		return cookieMap.get(name);
	}

	public String getValue(String name) throws IOException {
		Cookie cookie = cookieMap.get(name);
		if (cookie == null) {
			return null;
		}
		return URLDecoder.decode(cookie.getValue(), "utf-8");
	}

	public boolean exists(String name) {
		return cookieMap.get(name) != null;
	}

	public static Cookie createCookie(String name, String value)
			throws IOException {
		return new Cookie(name, URLEncoder.encode(value, "utf-8"));
	}

	public static Cookie createCookie(String name, String value, String path, 
			int maxAge) throws IOException {
		Cookie cookie = new Cookie(name, URLEncoder.encode(value, "utf-8"));
		cookie.setPath(path);
		cookie.setMaxAge(maxAge);
		return cookie;
	}

	public static Cookie createCookie(String name, String value, String domain,
			String path, int maxAge) throws IOException {
		Cookie cookie = new Cookie(name, URLEncoder.encode(value, "utf-8"));
		cookie.setDomain(domain);
		cookie.setPath(path);
		cookie.setMaxAge(maxAge);
		return cookie;
	}
}

9.3 ์ฟ ํ‚ค๋ฅผ ์‚ฌ์šฉํ•œ ๋กœ๊ทธ์ธ ์ƒํƒœ ์œ ์ง€ p. 226

๋กœ๊ทธ์ธ ์ƒํƒœ๋ฅผ ํ™•์ธํ•  ๋•Œ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ๋ฐ”๋กœ ์ฟ ํ‚ค๋ฅผ ์ด์šฉํ•˜๋Š” ๊ฒƒ์ด๋‹ค.
์ฟ ํ‚ค๋ฅผ ์ด์šฉํ•˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์œผ๋กœ ๋กœ๊ทธ์ธ ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค.

1. ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด ํŠน์ • ์ด๋ฆ„์„ ๊ฐ–๋Š” ์ฟ ํ‚ค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค.
2. ํ•ด๋‹น ์ฟ ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋ฉด ๋กœ๊ทธ์ธํ•œ ์ƒํƒœ๋ผ๊ณ  ํŒ๋‹จํ•œ๋‹ค.
3. ๋กœ๊ทธ์•„์›ƒํ•˜๋ฉด ํ•ด๋‹น ์ฟ ํ‚ค๋ฅผ ์‚ญ์ œํ•œ๋‹ค. 

ex) ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด "AUTH"๋ผ๋Š” ์ฟ ํ‚ค๋ฅผ ์ƒ์„ฑํ•˜๊ณ , "AUTH" ์ฟ ํ‚ค๊ฐ€ ์กด์žฌํ•˜๋ฉด ๋กœ๊ทธ์ธํ•œ ์ƒํƒœ๋ผ๊ณ  ์ธ์‹ํ•œ๋‹ค.


1) ๋กœ๊ทธ์ธ ์ฒ˜๋ฆฌ p. 227

์˜ˆ์ œ 9-11) loginForm.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head><title>๋กœ๊ทธ์ธํผ</title></head>
<body>

<form action="login.jsp" method="post">
์•„์ด๋”” <input type="text" name="id" size="10">
์•”ํ˜ธ <input type="password" name="password" size="10">
<input type="submit" value="๋กœ๊ทธ์ธ">
</form>

</body>
</html>

๊ฒฐ๊ณผ)

์˜ˆ์ œ 9-12) login.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.net.URLEncoder" %>
<%@ page import = "util.Cookies" %>
<%
	String id = request.getParameter("id");
	String password = request.getParameter("password");
	
	//id์™€ password๊ฐ€ ๊ฐ™์œผ๋ฉด ๋กœ๊ทธ์ธ ํ•ด๋ผ(์ฟ ํ‚ค์— id๊ฐ’์„ ๋„ฃ์–ด๋ผ), ID์™€ ์•”ํ˜ธ๊ฐ€ ๊ฐ™์œผ๋ฉด ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•œ ๊ฒƒ์œผ๋กœ ํŒ๋‹จ.
	if (id.equals(password)) {
		//Cookie ํด๋ž˜์Šค ์ƒ์„ฑ 
		//Cookie cookie = new Cookie("id", URLEncoder.encode(id,"utf-8"));
		//response.addCookie(cookie);
		//Cookie ํด๋ž˜์Šค ์ƒ์„ฑ(util.Cookies๋ฅผ import)
		response.addCookie(
			Cookies.createCookie("AUTH", id, "/", -1)
		);
%>
<html>
<head><title>๋กœ๊ทธ์ธ์„ฑ๊ณต</title></head>
<body>

๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.

</body>
</html>
<%
	} else { // ๋กœ๊ทธ์ธ ์‹คํŒจ์‹œ
%>
<script>
alert("๋กœ๊ทธ์ธ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.");
history.go(-1);
</script>
<%
	}
%>

๋น„๋ฐ€๋ฒˆํ˜ธ๋„ 1234๋กœ ์ž…๋ ฅํ–ˆ๋‹ค

๊ฒฐ๊ณผ)

๊ฐœ๋ฐœ์ž ๋„๊ตฌ๋ฅผ ๋ˆŒ๋Ÿฌ์„œ AUTO = 1234 ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.


2) ๋กœ๊ทธ์ธ ์—ฌ๋ถ€ ํŒ๋‹จ

์˜ˆ์ œ 9-13) loginCheck.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.net.URLEncoder" %>    
<%@ page import = "util.Cookies" %>
<%
	Cookies cookies = new Cookies(request);
%>
<html>
<head><title>๋กœ๊ทธ์ธ์—ฌ๋ถ€ ๊ฒ€์‚ฌ</title></head>
<body>

<%
	if (cookies.exists("AUTH")) {
%>
์•„์ด๋”” "<%= cookies.getValue("AUTH") %>"๋กœ ๋กœ๊ทธ์ธ ํ•œ ์ƒํƒœ
<%
	} else {
%>
๋กœ๊ทธ์ธํ•˜์ง€ ์•Š์€ ์ƒํƒœ
<%
	}
%>
</body>
</html>

๊ฒฐ๊ณผ) 


3) ๋กœ๊ทธ์•„์›ƒ ์ฒ˜๋ฆฌ

์˜ˆ์ œ 9-14) logout.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import = "java.net.URLEncoder" %>    
<%@ page import = "util.Cookies" %>
<%
	response.addCookie(
		Cookies.createCookie("AUTH", "", "/", 0)
	);
%>
<html>
<head><title>๋กœ๊ทธ์•„์›ƒ</title></head>
<body>

๋กœ๊ทธ์•„์›ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.

</body>
</html>

๊ฒฐ๊ณผ)


CHAPTER 10 ํด๋ผ์ด์–ธํŠธ์™€์˜ ๋Œ€ํ™” 2 : ์„ธ์…˜

์ฑ…์˜ ๋ชฉ์ฐจ
01 ์„ธ์…˜ ์‚ฌ์šฉํ•˜๊ธฐ : session ๊ธฐ๋ณธ ๊ฐ์ฒด
1.1 ์„ธ์…˜ ์ƒ์„ฑํ•˜๊ธฐ
1.2 session ๊ธฐ๋ณธ ๊ฐ์ฒด
1.3 ๊ธฐ๋ณธ ๊ฐ์ฒด์˜ ์†์„ฑ ์‚ฌ์šฉ
1.4 ์„ธ์…˜ ์ข…๋ฃŒ
1.5 ์„ธ์…˜ ์œ ํšจ ๊ธฐ๊ฐ„
1.6 request.getSession()์„ ์ด์šฉํ•œ ์„ธ์…˜ ์ƒ์„ฑ

02 ์„ธ์…˜์„ ์‚ฌ์šฉํ•œ ๋กœ๊ทธ์ธ ์ƒํƒœ ์œ ์ง€
2.1 ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž ์ •๋ณด session ๊ธฐ๋ณธ ๊ฐ์ฒด์— ์ €์žฅํ•˜๊ธฐ
2.2 ์ธ์ฆ ์—ฌ๋ถ€ ํŒ๋‹จ
2.3 ๋กœ๊ทธ์•„์›ƒ ์ฒ˜๋ฆฌ

03 ์—ฐ๊ด€๋œ ์ •๋ณด ์ €์žฅ์„ ์œ„ํ•œ ํด๋ž˜์Šค ์ž‘์„ฑ

04 ์„œ๋ธ”๋ฆฟ ์ปจํ…์ŠคํŠธ์™€ ์„ธ์…˜

10.1 ์„ธ์…˜ ์‚ฌ์šฉํ•˜๊ธฐ : session ๊ธฐ๋ณธ ๊ฐ์ฒด

์„œ๋ฒ„ ์„ธ์…˜์„ ์‚ฌ์šฉํ•˜๋ฉด ํด๋ผ์ด์–ธํŠธ์˜ ์ƒํƒœ๋ฅผ ์ €์žฅํ•  ์ˆ˜ ์žˆ๋‹ค.
์ฟ ํ‚ค์™€์˜ ์ฐจ์ด์ : ์„ธ์…˜์€ ์›น ๋ธŒ๋ผ์šฐ์ €๊ฐ€ ์•„๋‹ˆ๋ผ ์„œ๋ฒ„์— ๊ฐ’์„ ์ €์žฅํ•œ๋‹ค.
์„œ๋ฒ„๋Š” ์„ธ์…˜์„ ์‚ฌ์šฉํ•ด์„œ ํด๋ผ์ด์–ธํŠธ ์ƒํƒœ๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์—, ๋กœ๊ทธ์ธํ•œ ์‚ฌ์šฉ์ž ์ •๋ณด๋ฅผ ์œ ์ง€ํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ์„ธ์…˜์„ ์‚ฌ์šฉํ•œ๋‹ค. 

1) ์„ธ์…˜ ์ƒ์„ฑํ•˜๊ธฐ
2) session ๊ธฐ๋ณธ ๊ฐ์ฒด
3) ๊ธฐ๋ณธ ๊ฐ์ฒด์˜ ์†์„ฑ ์‚ฌ์šฉ
4) ์„ธ์…˜ ์ข…๋ฃŒ
5) ์„ธ์…˜ ์œ ํšจ ๊ธฐ๊ฐ„
6) request.getSession()์„ ์ด์šฉํ•œ ์„ธ์…˜ ์ƒ์„ฑ

์ฐธ๊ณ : https://jddng.tistory.com/268

์ฐธ๊ณ : https://velog.io/@ggg4155/22.03.03-%EC%84%B8%EC%85%98-%EC%A0%95%EB%B3%B4-%EA%B0%80%EC%A0%B8%EC%98%A4%EA%B8%B0


10.2 ์„ธ์…˜์„ ์‚ฌ์šฉํ•œ ๋กœ๊ทธ์ธ ์ƒํƒœ ์œ ์ง€
1) ์ธ์ฆ๋œ ์‚ฌ์šฉ์ž ์ •๋ณด session ๊ธฐ๋ณธ ๊ฐ์ฒด์— ์ €์žฅํ•˜๊ธฐ p. 242

์˜ˆ์ œ 10-4) [1] sessionLogin.jsp
session ๊ธฐ๋ณธ ๊ฐ์ฒด์˜ ํŠน์ • ์†์„ฑ์„ ๋กœ๊ทธ์ธ ์ƒํƒœ ์ •๋ณด๋กœ ์‚ฌ์šฉํ•œ๋‹ค. 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String id = request.getParameter("id");
	String password = request.getParameter("password");
	
	// id์™€ ๋น„๋ฐ€๋ฒˆํ˜ธ๊ฐ€ ์ผ์น˜ํ•˜๋ฉด
	if (id.equals(password)){
		//id๊ฐ’์„ ์„ธ์…˜์— ์ €์žฅ(MEMBERID)
		session.setAttribute("MEMERID", id);
%>
<html>
<head><title>๋กœ๊ทธ์ธ ์„ฑ๊ณต</title></head>
<body>

๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ–ˆ์Šต๋‹ˆ๋‹ค.

</body>
</html>
<%
	} else {//๋กœ๊ทธ์ธ ์‹คํŒจ์‹œ
%>
<script>
alert("๋กœ๊ทธ์ธ์— ์‹คํŒจํ•˜์˜€์Šต๋‹ˆ๋‹ค.");
history.go(-1);
</script>
<%
	}
%>

์˜ˆ์ œ 10-5) [2] sessionLoginForm.jsp
[1] sessionLogin.jsp์— ์•„์ด๋””์™€ ์•”ํ˜ธ๋ฅผ ์ „์†กํ•˜๋Š” ํผ์„ ๋ณด์—ฌ์ฃผ๋Š” JSP ์ฝ”๋“œ

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head><title>๋กœ๊ทธ์ธํผ</title></head>
<body>

<form action="sessionLogin.jsp" method="post">
์•„์ด๋”” <input type="text" name="id" size="10">
์•”ํ˜ธ <input type="password" name="password" size="10">
<input type="submit" value="๋กœ๊ทธ์ธ">
</form>

</body>
</html>

๋น„๋ฐ€๋ฒˆํ˜ธ 1234 ์ž…๋ ฅํ•œ๋‹ค.

๊ฒฐ๊ณผ)


2) ์ธ์ฆ ์—ฌ๋ถ€ ํŒ๋‹จ

[1] sessionLogin.jsp์€ ๋กœ๊ทธ์ธ์— ์„ฑ๊ณตํ•˜๋ฉด MEMBERID ์†์„ฑ์— ๋กœ๊ทธ์ธ ์ƒํƒœ ์ •๋ณด๋ฅผ ๋ณด๊ด€ํ•œ๋‹ค. 
์˜ˆ์ œ 10-6)
[3] sessionLoginCheck.jsp
 session ๊ธฐ๋ณธ ๊ฐ์ฒด์˜ "MEMBERID" ์†์„ฑ์„ ์‚ฌ์šฉํ•ด์„œ ๋กœ๊ทธ์ธ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•œ๋‹ค.  

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
	String memberId = (String)session.getAttribute("MEMBERID");//๊ฐ•์ œํ˜•๋ณ€ํ™˜
	boolean login = memberId == null ? false : true;
%>      
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๋กœ๊ทธ์ธ์—ฌ๋ถ€ ๊ฒ€์‚ฌ</title>
</head>
<body>

<%
	if (login){
%>
์•„์ด๋”” "<%= memberId %>"๋กœ ๋กœ๊ทธ์ธ ํ•œ ์ƒํƒœ
<%
	} else {
%>
๋กœ๊ทธ์ธํ•˜์ง€ ์•Š์€ ์ƒํƒœ
<%
	}
%>
</body>
</html>

๊ฒฐ๊ณผ)


3) ๋กœ๊ทธ์•„์›ƒ ์ฒ˜๋ฆฌ

์˜ˆ์ œ 10-7) [4] sessionLogout.jsp
session.invalidate() ๋ฉ”์„œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์„ธ์…˜์„ ์ข…๋ฃŒํ•œ๋‹ค.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	session.invalidate();
%>    
    
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>๋กœ๊ทธ์•„์›ƒ</title>
</head>
<body>

๋กœ๊ทธ์•„์›ƒํ•˜์˜€์Šต๋‹ˆ๋‹ค.

</body>
</html>

๊ฒฐ๊ณผ)


10.3 ์—ฐ๊ด€๋œ ์ •๋ณด ์ €์žฅ์„ ์œ„ํ•œ ํด๋ž˜์Šค ์ž‘์„ฑ

10.4 ์„œ๋ธ”๋ฆฟ ์ปจํ…์ŠคํŠธ์™€ ์„ธ์…˜


728x90
๋ฐ˜์‘ํ˜•
Comments