๋ชฉ์ฐจ
1. 2023.12.15(๊ธ)
โ ์ฟ ํค(Cookie)์ ์ธ์ โ
โ ์ฟ ํค(Cookie)
- ์ฟ ํค๋ ํด๋ผ์ด์ธํธ์ ๋ํ ์ ๋ณด๋ฅผ ํด๋ผ์ด์ธํธ์ ํ๋๋์คํฌ์ ์์ ํ์ผ ํํ๋ก ์ ์ฅํ ๊ฒ์ผ๋ก ์๋ฒ์์ ์ฌ์ฉ์์๊ฒ ํธ๋ฆฌํ ๊ธฐ๋ฅ์ ์ ๊ณตํ๊ธฐ ์ํด ๋ง์ด ์ฌ์ฉ๋๊ณ , ์ด ์ฟ ํค๋ ์น ๋ธ๋ผ์ฐ์ ์ ์ํด ๊ด๋ฆฌ๋๋ค.
- ์ฟ ํค๋ ํ ์คํธ ํํ๋ก ์ ์ฅ๋๊ธฐ ๋๋ฌธ์ ๋ณ์กฐ๋ ๋ณต์ฌ๋ฑ์ด ๊ฐ๋ฅํ์ฌ ๋ณด์์ฑ์ด ์๊ณ ํด๋ผ์ด์ธํธ์... ์์ ์๋ ์ด 300
๊ฐ ๊น์ง ์ ์ฅ ๊ฐ๋ฅํ์ผ๋ฉฐ,
๊ฐ ๋๋ฉ์ธ ๋น ๊ฐฏ์ ์ ํ(20๊ฐ)์ด๋ ํฌ๊ธฐ ์ ํ(4096Byte)์ ์ฌ์ค์ ๋ฌด์๋ฏธํด์ ธ ๊ฐ๊ณ ์๋ค.
- ์ ์ฅ๋๋ ์์น๋ ์์คํ
(์ด์์ฒด์ )์ด๋ ๋ธ๋ผ์ฐ์ ์ ๋ฐ๋ผ ๋ค๋ฅด๋ฉฐ ์ผ๋ฐ์ ์ธ ํ์(๊ณ์ ๋ช
@๋๋ฉ์ธ)๋ ๊พธ์คํ ๋ฐ๋์ด ๊ฐ๊ณ ์๋ค.
- ์ฟ ํค๋ ์น ๋ธ๋ผ์ฐ์ ๊ฐ ๊ฑฐ์ณ๊ฐ ์น์ฌ์ดํธ ๋ฐ ๊ฐ์ธ์ ์ ๋ณด๊ฐ ๊ธฐ๋ก๋๊ธฐ ๋๋ฌธ์ ๊ฐ์ธ์ ์ฌ์ํ์ ์นจํดํ ์์ง๊ฐ ์์ผ๋ฉฐ, ์ด๋ก ์ธํด ์น ๋ธ๋ผ์ฐ์ ์์ฒด์ ์ฟ ํค ๊ฑฐ๋ถ ๊ธฐ๋ฅ์ด ํฌํจ๋์ด ์๋ค.
ํ์ง๋ง, ์ฟ ํค ๊ฑฐ๋ถ ๊ธฐ๋ฅ์ ์ค์ ํ๊ฒ ๋๋ฉด ์น ๋ธ๋ผ์ฐ์ ์์ ์ฐ๊ฒฐ์ ์ง์์ํค์ง ๋ชปํ๊ธฐ ๋๋ฌธ์ ๋ฌธ์ ๊ฐ ๋ฐ์ํ๊ฒ ๋๋ค.
(์ฌ์ค์ ๊ฑฐ๋ถํ๋ ์๋ฏธ๊ฐ ์์... ๋ฐ ๊ฐ์ ์ )
- ์ฟ ํค์ ๋์ ๋ฐฉ์
์ฟ ํค์ ๋์ ๋ฐฉ์์ ์น ์๋ฒ์ ์น ๋ธ๋ผ์ฐ์ ๊ฐ์ ์ํธ ํ๋ ฅ์ผ๋ก ์ด๋ฃจ์ด์ง๋ค. ์น ์๋ฒ๊ฐ ์ธ๋ถ ๋ธ๋ผ์ฐ์ ์ ์์ฒญ์ ์๋ตํ ๋ HTTP ํ๋กํ ์ฝ์ ์๋ HTTP ํค๋ ์ฟ ํค ์ ๋ณด๋ฅผ ํฌํจ์์ผ ํด๋ผ์ด์ธํธ ์ชฝ์ผ๋ก ๋ณด๋ธ๋ค.
๊ทธ๋ฆฌ๊ณ , ์น ๋ธ๋ผ์ฐ์ ๊ฐ ์น ์๋ฒ์ ์กด์ฌํ๋ ํ์ด์ง๋ฅผ ์๊ตฌํ ๋ ๊ทธ ์ ์ ์์ ์ด ๋ฐฉ๋ฌธํ์ ๋ ํด๋น ํ์ด์ง์ ๋ํด ์น ์๋ฒ๊ฐ ์น ๋ธ๋ผ์ฐ์ ์ชฝ์ผ๋ก ์ฌ์ด๋์๋ ์ฟ ํค๋ฅผ ์น ์๋ฒ๋ก ๋ค์ ๊ฑด๋ค ์ฃผ์ด์ ์ด์ ์ํ๋ฅผ ์น ์๋ฒ๊ฐ ์ ์ ์๋๋ก ํ๋ค.
- ์ฟ ํค(๊ฐ์ฒด)์ ํ๋ผ๋ฏธํฐ(์์ฑ)
·name=value
: ์ฟ ํค๋ ๋ฐ๋์ ์ด๋ฆ์ ํฌํจํด์ผ ํ๋ค. ์ด๋ฆ์ ๋ณ์๋ช
๊ณผ ๊ฐ์ ๋ชฉ์ ์ผ๋ก ์ฌ์ฉํ๋ค.
·expires=date
: ์ ํจ๊ธฐ๊ฐ์ ์ง์ ํ๋ค.
๋ ์ง๋ฅผ ์๋ตํ ๊ฒฝ์ฐ ๋ธ๋ผ์ฐ์ ์ข
๋ฃ ์์ ๊น์ง ์ฟ ํค๊ฐ ๋จ์์๊ฒ ๋๋ค. ์ ํจ๊ธฐ๊ฐ ์ค์ ์ ๊ทธ๋ฆฌ๋์น ํ์ค์(Wdy, DD-Mon-TT HH:MM:SS GNT)๋ก ์ค์ ํ๊ฒ ๋๋ค.
·path=path
: ์น ์๋ฒ์์ ์ฟ ํค ๊ฐ์ด ๋๋ ํฐ๋ฆฌ ๊ฐ์ ์ ํจํ ๋ฒ์๋ฅผ ์ค์ ํ๋ ๊ฒ์ผ๋ก path ๊ฐ์ ์น ์๋ฒ์ document root ๋ฅผ ๊ธฐ์ค์ผ๋ก ์ค์ ํ๋ค.
์๋ฅผ ๋ค์ด... path ๊ฐ ใ/ใ์ด๋ฉด (ใ"Path=/;"ใ) ๋๋ฉ์ธ์ ๋ฃจํธ(/)์์ ์์ํ๋ ๋ชจ๋ ๊ณณ์ ์ ์ํ ๋ ํด๋น ์ฟ ํค์ ๊ฐ์ ์ ์ฉํ ์ ์๋ค.
์๋ตํ ๊ฒฝ์ฐ ํ์ฌ ๋ฌธ์์ ์์น์ ๋๋ ํฐ๋ฆฌ์ ํ์ ๋๋ ํฐ๋ฆฌ๊ฐ ์ฟ ํค์ ๋ฒ์๊ฐ ๋๋ค.
·domain=domain
: ํ์ฌ์ดํธ์์ ๋ง๋ ์ฟ ํค๊ฐ ๋ค๋ฅธ ์ฌ์ดํธ์ ์ํฅ์ ์ฃผ์ง ์๊ธฐ ๋๋ฌธ์ ๋๋ฉ์ธ ํญ๋ชฉ์ด ํ์ํ๋ค. ๋๋ฉ์ธ์ ์๋์ผ๋ก ์ฌ์ดํธ์ ๊ธฐ๋ณธ ๋๋ฉ์ธ์ผ๋ก ์ค์ ๋๋ค.
·secure
: ๋ฐ์ดํฐ์ ์ ์ก์ ๋ณด์์ด ์๊ตฌ๋๋ ์ง๋ฅผ ์ง์ ํ๋ค. true๋ ๋ธ๋ผ์ฐ์ ๊ฐ ์์ ํ๋ค๊ณ ํ๋จํ๋ ์๋ฒ๋ง ๋ํ๋๊ฒ ๋๋ค. ๊ธฐ๋ณธ๊ฐ(default)์ false ์ด๋ค.
- ์ฟ ํค์ ๊ธฐ๋ณธ ์ค์
โ Cooke ๊ฐ์ฒด ์์ฑ
Cookie c = new Cookie("์ฟ ํค์ด๋ฆ","์ฟ ํค๊ฐ");
โก Cooke ๊ฐ์ฒด ์ค์
c.setMaxAge(์ฟ ํค์ ํจ์๊ฐ ์ด ๋จ์ ์ค์ )
โข Cookie ๊ฐ์ฒด ๋ฑ๋ก(์ถ๊ฐ)
response.addCookie(c);
- JSP ์์ ์ฟ ํค๋ฅผ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ๋ ๊ฐ์ง๊ฐ ์๋ค.
์ฒซ ๋ฒ์งธ ๋ฐฉ๋ฒ์
ใresponseใ๊ฐ์ฒด์ ใsetHeader()ใ ๋ฉ์๋๋ฅผ ์ด์ฉํ์ฌ ์ฟ ํค๋ฅผ ์ค์ ํ๋ ๊ฒ์ด๋ค.
ํ์ง๋ง, ๊ถ์ฅํ์ง ์๋๋ค.
ex) response.setHeader("set_cookie","name=value, expirese=value, ...");
//-- ์ด ๋ฐฉ๋ฒ์...
// Header ์ key ์ ๊ฐ, key ์ ๊ฐ, .... ์ String Type ์ผ๋ก ๋๊ธฐ๋ ๊ฒ์ด๊ธฐ ๋๋ฌธ์ ์๋ฐํ ๋งํ์๋ฉด ์ฟ ํค๋ผ๋ ๊ฐ์ฒด๋ฅผ ๋๊ธฐ๋ ๊ฒ์ด ์๋๋ค. ๊ณผ๊ฑฐ์๋ ์ฟ ํค๋ผ๋ ํด๋์ค๊ฐ ์กด์ฌํ์ง ์์๊ธฐ ๋๋ฌธ์ ์ด ๋ฐฉ๋ฒ์ ์ฌ์ฉํ์๋ค.
๋ ๋ฒ์งธ ๋ฐฉ๋ฒ์
ใCookieใ ํด๋์ค๋ฅผ ์ด์ฉํ๋ ๋ฐฉ๋ฒ์ด๋ค.
· String getCommet()
: ์ฟ ํค์ ๋ํ ์ค๋ช ์ ๊ฐ์ ธ์จ๋ค.
· String getDomatin()
: ์ฟ ํค๊ฐ ์ ํจํ ๋๋ฉ์ธ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์จ๋ค.
· int getMaxAge()
: ์ฟ ํค์ ์ ํจํ ์๊ฐ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์จ๋ค.
· String getName()
: ์ฟ ํค์ ์ด๋ฆ์ ๊ฐ์ ธ์จ๋ค.
· String getPath()
: ์ฟ ํค์ ์ ํจํ ๋๋ ํฐ๋ฆฌ ์ ๋ณด๋ฅผ ๊ฐ์ ธ์จ๋ค.
· String getSecure()
: ์ฟ ํค์ ๋ณด์ ์ค์ ์ ๊ฐ์ ธ์จ๋ค.
· String getValue()
: ์ฟ ํค์ ํด๋น ๊ฐ์ ๊ฐ์ ธ์จ๋ค.
· int getVersion()
: ์ฟ ํค์ ๋ฒ์ ๊ฐ์ ๊ฐ์ ธ์จ๋ค.
· void setcomment(string purpose)
: ์ฟ ํค์ ๋ํ ์ค๋ช
์ ์ค์ ํ๋ค.
· void setDomain(String Pattern)
: ์ฟ ํค๊ฐ ์ ํจํ ๋๋ฉ์ธ ์ ๋ณด๋ฅผ ์ค์ ํ๋ค.
· void setMaxAge(int expiry)
: ์ฟ ํค๊ฐ ์ ํจํ ์๊ฐ ์ ๋ณด๋ฅผ ์ค์ ํ๋ค.
· void setSecure(string url)
: ์ฟ ํค์ ๋ณด์ ์ค์ ๊ฐ์ ๊ตฌ์ฑํ๋ค.
· void setValue(String newValue)
: ์ฟ ํค์ ํด๋น ๊ฐ์ ์ค์ ํ๋ค.
· void setVersion(int V)
: ์ฟ ํค์ ๋ฒ์ ๊ฐ์ ์ค์ ํ๋ค.
- JSP ์์ ์ฟ ํค(Cookie) ์ ํจ์๊ฐ ์ค์
ใsetMaxAge(int expiry)ใ ๋ฉ์๋๋ฅผ ํตํด ์ ํจ์๊ฐ์ ์ค์ ํ
· ใexpiryใ๊ฐ ใ์์ใ์ผ ๋
: ๋ธ๋ผ์ฐ์ ๊ฐ ์ข
๋ฃ๋๋ฉด ์ฟ ํค๊ฐ ์ ๊ฑฐ๋๋ค.
· ใexpiryใ๊ฐ ใ0ใ์ผ ๋
: ์์ฑ๊ณผ ๋์์ ์ฟ ํค๊ฐ ์ ๊ฑฐ๋๋ค.
· ใexpiryใ๊ฐ ใ์์ใ์ผ ๋
: ์ด ๋จ์๋ก ํด๋น ์๊ฐ๋งํผ ์ฟ ํค๊ฐ ์ ์ง๋๋ค.
· ใsetMaxAge()ใ ๋ฉ์๋๋ฅผ ํตํด ์ ํจ์๊ฐ์ ์ค์ ํ์ง (๋ช
์ํ์ง)์์ ๊ฒฝ์ฐ ๊ธฐ๋ณธ์ ์ผ๋ก ์์๊ฐ ์ค์ ๋์ด ๋ธ๋ผ์ฐ์ ๊ฐ ์ข
๋ฃ๋ ๋๊น์ง ์ฟ ํค๊ฐ ์ ์ง๋๋ค.
โ ์ธ์ (Session)
- ์ฟ ํค์ ๊ฒฝ์ฐ ๋ธ๋ผ์ฐ์ ์ ์ํ๋ฅผ ์ ์งํ๊ธฐ ์ํ ์ ๋ณด๋ฅผ ์ ์ฅํ์ง๋ง(์ฆ, ๋ก์ปฌ PC์ ํ๋๋์คํฌ์ ์ ์ฅ) ์ธ์ ์ ์๋ฒ์ ์น ์ปจํ ์ด๋์ ์ํ๋ฅผ ์ ์งํ๊ธฐ ์ํ ์ ๋ณด๋ฅผ ์ ์ฅํ๋๊ฒ์ผ๋ก
ใjavax.servvlet.httpใ ํจํค์ง์ ใHttpSessionใ ์ธํฐํ์ด์ค๋ฅผ ํตํด ์ธ์ ์ ์ฌ์ฉํ๊ฒ ๋๋ค.
๋ํ ์ธ์ ์ ์๋ฒ์ ๊ด๋ จ๋ ์ ๋ณด๋ฅผ ๋ ธ์ถํ์ง ์๊ธฐ ๋๋ฌธ์ ์ฟ ํค๋ฅผ ์ฌ์ฉํ๋ ๊ฒ๋ณด๋ค ใHttpSessionใ ์ธํฐํ์ด์ค์ ์ธ์
์ ํตํ ๊ด๋ฆฌ๊ฐ ๋ณด๋ค ์์ ์ (๋ณด์์ฑ ํฅ์)์ด๋ผ ํ ์ ์๋ค.
- Session ์์ฑ
Session ์ ์์ฑํ๊ธฐ ์ํด์๋ ํ์ด์ง ๋๋ ํฐ๋ธ(page directive)์ session ์์ฑ์ ture ๋ก ์ค์ ํ๋ค.
(๋ณ๋๋ก ์ค์ ํ์ง ์์๋ ์๋์ผ๋ก ๊ธฐ๋ณธ๊ฐ ์ ์ฉ. ์ฆ, ์ฌ์ฉํ์ง ์์ ๊ฒฝ์ฐ๋ง false ์ค์ .)
ex) <%@ page session="true"%>
- Session ๋ด์ฅ ๊ฐ์ฒด์ ์ฃผ์ ๋ฉ์๋
· String getId()
: (ใ์ธ์ ์์ด๋ใ๋ผ๊ณ ํ๋ค. ์ธ์ ๊ณ ์ ID๋ฅผ ๋ฌธ์์ด ํํ๋ก ๋ฐํํ๋ค.)
· long getCreationTime()
: ์ธ์ ์ ์์ฑ๋ ์๊ฐ์ ๊ตฌํ๋ค.
(์๊ฐ์ 1970๋ 1์ 1์ผ ์ดํ ํ๋ฌ๊ฐ ์๊ฐ์ ์๋ฏธํ๋ค.)
· long getLastAccessedTime()
: ์น ๋ธ๋ผ์ฐ์ ๊ฐ ๊ฐ์ฅ ๋ง์ง๋ง์ ์ธ์ ์ ์ ๊ทผํ ์๊ฐ์ ๊ตฌํ๋ค.
· int getMaxInactiveInerval()
: ์ธ์ ์ ์ง ์๊ฐ์ ์ด๋ก ๋ฐํํ๋ค. ๊ธฐ๋ณธ๊ฐ์ 30๋ถ์ผ๋ก ์ง์ ๋๋ค.
· void setMaxInactiveInerval(int interval)
: ์ธ์ ์ ์ ์งํ ์๊ฐ์ interval ์ ์ค์ ๋ ์ด ๊ฐ์ผ๋ก ์ค์ ํ๋ค.
· void invalidate()
: ํ์ฌ ์ธ์ ์ ์ข ๋ฃํ๋ค. ์ธ์ ๊ณผ ๊ด๋ จ๋ ๋ชจ๋ ๊ฐ์ ์ญ์ ํ๋ค.
· boolean isNew()
: ํด๋ผ์ด์ธํธ ใ์ธ์ ์์ด๋ใ๋ฅผ ํ ๋นํ์ง ์์ ๊ฒฝ์ฐ ใtrueใ๊ฐ์ ๋ฐํํ๋ค.
์๋ก์ด ์ธ์ ์ธ์ง์ ์ฌ๋ถ๋ฅผ ํ์ธํ ๋ ์ฌ์ฉํ๋ค.
· void setAttribue(String key, Objec value)
: ์ฃผ์ด์ง key ์์ฑ์ ๊ฐ์ value ๋ก ์ง์ ํ๋ค.
· Object getAttribute(String key)
: ์ฃผ์ด์ง key ์์ฑ์ ๊ฐ์ ์ป์ด๋ธ๋ค.
· void removeAttribue(String key)
: ์ฃผ์ด์ง key ์์ฑ์ ๊ฐ์ ์ ๊ฑฐํ๋ค.
- ํ๋ฒ ์์ฑ๋ ์ธ์
์ ์ข
๋ฃํ๊ธฐ ์ ๊น์ง ์ง์์ ์ผ๋ก ์ ์ง๋๋ค. (์ค๊ฐ์ ์ฌ๋ผ์ง์ง ์์)
๋จ, ์ํ ์ธํฐ๋ท ๋ฑ
ํน๊ณผ ๊ฐ์ ์๋น์ค ์ด์ฉ ์ ์ผ์ ์๊ฐ ๋์ ์ฌ์ฉํ์ง ์์ผ๋ฉด ๋กํฌ์ธ ์ด ํ๋ฆฌ๋ ๊ฒ ๊ฐ์ ์ด์ ๋
์์๋ก ์ค์ ์ ํด๋์๊ธฐ ๋๋ฌธ์ด๋ฉฐ, ์ด๋ ๊ฒ ์์๋ก ์ธ์
์ ์ข
๋ฃํ๊ธฐ ์ ๊น์ง๋ ์ง์์ ์ผ๋ก ์ ์ง๋๋ค.
์ด์ ๊ฐ์ ์ฑ๊ฒฉ์ผ๋ก ์น ์ดํ๋ฆฌ์ผ์ด์
์ ์คํํ๋ ๋์ ์ง์์ ์ผ๋ก ์ฌ์ฉํ๋ ๋ฐ์ดํฐ์ ์ ์ฅ ์ฅ์๋ก๋ ์ธ์
์ด ์ ํฉ(์ ๋น)ํ๋ค.
โป ์ฐธ๊ณ
- ์ค์ฝํ(scope) -> ๋๋ถ๋ถ์ ๊ต์ฌ์์ life cycle (์๋ช ์ฃผ๊ธฐ)๋ก ์ค๋ช ํจ.
์น ์ดํ๋ฆฌ์ผ์ด์ ์ page, request, session, application ์ด๋ผ๋ 4๊ฐ์ ๊ฐ์ฒด์ ์์ญ์ ๊ฐ์ฒด์ ์ ํจ๊ธฐ๊ฐ์ด๋ผ๊ณ ๋ ๋ถ๋ฆฌ๋ฉฐ, ๊ฐ์ฒด๋ฅผ ๋๊ตฌ์ ๊ณต์ํ ๊ฒ์ด๊ฐ๋ฅผ ๋ํ๋ธ๋ค.
· page ์์ญ
ํ ๋ฒ์ ์น ๋ธ๋ผ์ฐ์ (ํด๋ผ์ด์ธํธ)์ ์์ฒญ์ ๋ํด ํ๋์ JSp ํ์ด์ง๊ฐ ํธ์ถ ๋๋ฉฐ ์น ๋ธ๋ผ์ฐ์ ์ ์์ฒญ์ด ๋ค์ด์ค๋ฉด ์ด
๋... ๋จ ํ๊ฐ์ ํ์ด์ง๋ง ๋์๋๋ค.
· request ์์ญ
ํ ๋ฒ์ ์น ๋ธ๋ผ์ฐ์ (ํด๋ผ์ด์ธํธ)์ ์์ฒญ์ ๋ํด ๊ฐ์ ์์ฒญ์ ๊ณต์ ํ๋ ํ์ด์ง๊ฐ ๋์๋๋ฉฐ ์น๋ฅด๋ผ์ฐ์ ์ ํ ๋ฒ์ ์
์ฒญ์ด ๋จ์ง ํ ๊ฐ์ ํ์ด์ง๋ง ์์ฒญ๋ ์ ์๊ณ ๊ฐ์ request ์์ญ์ด๋ฉฐ ๋ ๊ฐ์ ํ์ด์ง๊ฐ ๊ฐ์ ์์ฒญ์ ๊ณต์ ํ๋ค.
(include ์ก์ ํ๊ทธ, forward ์ก์ ํ๊ทธ ์ฌ์ฉ ์)
· seession ์์ญ
ํ๋์ ์น ๋ธ๋ผ์ฐ์ ๋น ํ๊ฐ์ Session ๊ฐ์ฒด๊ฐ ์์ฑ๋๋ค. ๊ฐ์ ์น ๋ธ๋ผ์ฐ์ ๋ด์์๋ ์์ฒญ๋๋ ํ์ด์ง๋ค์ด ๊ฐ์ ๊ฐ
์ฒด๋ฅผ ๊ณต์ ํ๋ค.
· applicaiton ์์ญ
ํ๋์ ์น ์ดํ๋ฆฌ์ผ์ด์ ๋น ํ ๊ฐ์ application ๊ฐ์ฒด๊ฐ ์์ฑ๋๋ค. ๋๋ถ๋ถ์ ํ๊ฒฝ ์ค์ ์์ ์ฌ์ฉ๋๋ค. ๊ฐ์ ์น ์ดํ๋ฆฌ
์ผ์ด์ ์์ ์์ฒญ๋๋ ํ์ด์ง๋ค์ ๊ฐ์ ๊ฐ์ฒด๋ฅผ ๊ณต์ ํ๋ค.
F_WebApp13: ์ธ์ ์ฒ๋ฆฌ-๋ก๊ทธ์ธ
ใด/WebApp13/WebContent





ใดใดTestSession01.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// ์ต์ด ์์ฒญ์ผ ๊ฒฝ์ฐ... ์๋ฌด๊ฒ๋ ์์ง๋ง...
// TEstSession01_ok.jsp ํ์ด์ง์์
// ๋ก๊ทธ์ธ ์ฑ๊ณต ํ์ ์์ฒญ๋ ํ์ด์ง๋ผ๋ฉด...
// session์ userId์ superman ์
// userName ์ ๋ฌธ์ ํ์ ๋ด์์ ๋ณด๋ธ ์ํฉ
String userId = (String)session.getAttribute("userId"); // "superman"
String userName = (String)session.getAttribute("userName"); // "๋ฌธ์ ํ"
//-- ใsession.getAttribute("userId");ใ๋
// Object ํ์
์ ๋ฐํํ๋ฏ๋ก
// String ํ์
์ผ๋ก ๋ฐํํ๋ ๊ณผ์ ํ์(๋ค์ด ์บ์คํ
)
// ์ถ๊ฐ~!!!
// ์ธ์
ํ์ฑํ ์๊ฐ ๋ณ๊ฒฝ -----------------------------------------------------------
// โป ์ธ์
๊ธฐ๋ณธ(default) ์๊ฐ์ 1800์ด.
session.setMaxInactiveInterval(10);
//--- ์ธ์
์ด ์ ์ง๋๋ ์๊ฐ์ 10์ด๋ก ์ค์ ํ ์ํ.
// ์ด๋ก ์ธํด...
// ๋ก๊ทธ์ธ ํ 10 ์ด ๋์ ์๋ฌด ์ก์
๋ ์๋ ์ํ์์...
// ๋ค์ ๊ธฐ๋ฅ์ ์ด์ฉํ๋ ค ํ๊ฑฐ๋, ํ์ด์ง ์๋ก๊ณ ์นจ์ ์ํํ๋ฉด
// ๋ก๊ทธ์์ ์ฒ๋ฆฌ๋ ๊ฒ์ ํ์ธํ ์ ์๋ค.
// ------------------------------------------------------------์ธ์
ํ์ฑํ ์๊ฐ ๋ณ๊ฒฝ
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSession01</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/MemberScore.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<style type="text/css">
/* .btnMenu{border: 1px solid gray;border-radius: 3px;font-size: 8px;width: 60px;height: 20px;} */
.btn_box [type="button"], .btn_box [type="reset"], .btn{min-width: 80px;}
</style>
<script type="text/javascript">
function sendIt()
{
// ํ์ธ
//alert("ํจ์ ํธ์ถ");
var f = document.myForm;
if(!f.userId.value)
{
alert("์์ด๋๋ฅผ ์
๋ ฅํด์ผ ํฉ๋๋ค~!!!");
f.userId.focus();
return;
}
if(!f.userPwd.value)
{
alert("ํจ์ค์๋๋ฅผ ์
๋ ฅํด์ผ ํฉ๋๋ค~!!!");
f.userPwd.focus();
return;
}
f.submit();
}
</script>
</head>
<body class="section">
<!-- **Session์ ์๋ฒ์ชฝ ์์์ด๋ฏ๋ก ๋จผ์ ๋ณผ ๊ฒ** -->
<div>
<h1>์ธ์
์ฒ๋ฆฌ - ๋ก๊ทธ์ธ</h1>
</div>
<div class="layout">
<div class="tbl_box">
<table>
<tr>
<td class="btn_box" style="display:flex;align-items: center;">
<a href="">
<button type="button" class="btnMenu btn01">๊ฒ์ํ</button>
</a> |
<%
if(userId == null)
{
%>
<a href="">
<button type="button" class="btnMenu btn02">์ผ์ ๊ด๋ฆฌ</button>
</a> |
<a href="">
<button type="button" class="btnMenu btn02">์น๊ตฌ๊ด๋ฆฌ</button>
</a> |...
<%
}
else
{
%>
<a href="Sca.jsp">
<button type="button" class="btnMenu btn01">์ผ์ ๊ด๋ฆฌ</button>
</a> |
<a href="Fir.jsp">
<button type="button" class="btnMenu btn01">์น๊ตฌ๊ด๋ฆฌ</button>
</a> |...
<%
}
%>
</td>
</tr>
</table>
</div>
<div class="tbl_box">
<%
if(userId == null)
{
%>
<form action="TestSession01_ok.jsp" method="post" name="myForm">
<table>
<tr>
<th>์์ด๋</th>
<td>
<input type="text" name="userId" class="txt">
</td>
</tr>
<tr>
<th>ํจ์ค์๋</th>
<td>
<!-- <input type="text"> -->
<input type="text" name="userPwd" class="txt">
</td>
</tr>
<tr>
<td colspan="2">
<button type="button" class="btn" style="width:100%;" onclick="sendIt();">๋ก๊ทธ์ธ</button>
</td>
</tr>
</table>
</form>
<%
}
else
{
%>
<h2><%=userName %>(<%=userId %>)๋, ํ์ํฉ๋๋ค.</h2>
<p>์ด์ , ์ผ์ ๊ด๋ฆฌ์ ์น๊ตฌ๊ด๋ฆฌ ์๋น์ค๋ฅผ ์ด์ฉํ ์ ์์ต๋๋ค.</p>
<p class="btn_box">
<a href="Logout.jsp">
<button type="button" class="btnMenu btn01">๋ก๊ทธ์์</button>
</a>
</p>
<%
}
%>
</div>
</div>
</body>
</html>
ใดใดTestSession01_ok.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// TestSession01_ok.jsp
// ์ด์ ํ์ด์ง(TestSession01.jsp)๋ก ๋ถํฐ ๋์ด์จ ๋ฐ์ดํฐ ์์
// -> userId, userPwd
String userId = request.getParameter("userId");
String userPwd = request.getParameter("userPwd");
// DB ํ์ฉ -> dao ๋ก๊ทธ์ธ ์ฒ๋ฆฌ -> dao ํ์ฉ
// -> ๋ก๊ทธ์ธ ๊ด๋ จ ํ
์ด๋ธ ๋ฐ์ดํฐ์ ๋น๊ต -> ์ต์ข
์ ์ผ๋ก ๋ก๊ทธ์ธ ์ก์
์ฒ๋ฆฌ
String memberId = "superman";
String memberPwd = "1234567";
String memberName = "๋ฌธ์ ํ";
if(userId.equals(memberId) && userPwd.equals(memberPwd))
{
// ๋ก๊ทธ์ธ ์ก์
์ฒ๋ฆฌ
session.setAttribute("userId", userId); //-- session ์ userId -> superman
session.setAttribute("userName", memberName); //-- session ์ userName -> ๋ฌธ์ ํ
// ํด๋ผ์ด์ธํธ๊ฐ ํ์ด์ง๋ฅผ ๋ค์ ์์ฒญํ ์ ์๋๋ก ์๋ด
response.sendRedirect("TestSession01.jsp");
}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSession01_ok.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div class="layout">
<h1>๋ก๊ทธ์ธ ์คํจ~!!!</h1>
<hr>
</div>
<a href="TestSession01.jsp">โถ ๋ก๊ทธ์ธ ํ์ด์ง๋ก ๋์๊ฐ๊ธฐ</a>
</body>
</html>
ใดใดLogout.jsp
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// Logout.jsp
//-- ์ธ์
์ ๋ด์ฉ์ ์์ ๋ก๊ทธ์์ ์ฒ๋ฆฌ
// ์ดํ ... ํด๋ผ์ด์ธํธ๊ฐ ๋ค์ ์์ฒญํ ํ์ด์ง ์๋ด
session.removeAttribute("userId");
session.removeAttribute("userName");
// ์ธ์
์ ์ฌ์ฉ์์์ด๋์ ์ด๋ฆ ์ญ์
// ๊ธฐ์กด ์ธ์
์ ์ ์ฅ๋์ด ์๋ ๋ชจ๋ ํญ๋ชฉ์ ์ ๊ฑฐํ๊ณ ์ผ์
์ ์ด๊ธฐํ
session.invalidate();
// ํด๋ผ์ด์ธํธ์๊ฒ ๋ค์ ๋ก๊ทธ์ธ ํ์ด์ง๋ฅผ ์์ฒญํ ์ ์๋๋ก ์๋ด
response.sendRedirect("TestSession01.jsp");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Logout.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div class="layout">
<h1>์์ ํ๊ฒ~!๋ก๊ทธ์์ ์ฒ๋ฆฌ๋์์ต๋๋ค~!!!</h1>
</div>
</body>
</html>
F_WebApp14: ํ์๊ฐ์ 01-03(์ด๋ฆ,์ ํ๋ฒํธ)(์์ด๋,ํจ์ค์๋),(์ด๋ฆ,์ ํ๋ฒํธ,์์ด๋, ํจ์ค์๋ ์ถ๋ ฅ)
ใด/WebApp14/WebContent



ใดใดTestSession01.jsp_ํ์๊ฐ์ 01 (์ด๋ฆ, ์ ํ๋ฒํธ)
<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSession01.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<!--
โ TestSession01.jsp ์์ TestSession02.jsp ํ์ด์ง๋ก
์ด๋ฆ๊ณผ ์ ํ๋ฒํธ๋ฅผ ์
๋ ฅ๋ฐ์ ์ ์ก
TestSession02.jsp์์ TestSession03.jsp ํ์ด์ง๋ก
์์ด๋์ ํจ์ค์๋๋ฅผ ์
๋ ฅ๋ฐ๊ณ
์์์ ์ ๋ฌ๋ฐ์ ์ด๋ฆ๊ณผ ์ ํ๋ฒํธ๋ฅผ ํจ๊ป ์ ์ก
TestSession03.jsp ์์ ์ ๋ฌ๋ฐ์ ์ด๋ฆ, ์ ํ๋ฒํธ, ์์ด๋, ํจ์ค์๋ ์ถ๋ ฅ
01 ---------------- 02 ----------------- 03
์ด๋ฆ, ์ ํ ์์ด๋, ํจ์ค์๋ ์ด๋ฆ, ์ ํ, ์์ด๋, ํจ์ค์๋
์
๋ ฅ ์
๋ ฅ ์ถ๋ ฅ
-getParameter - getAttribute
โป ์ฆ, 01์์ 02๋ก ๋๊ฒจ๋ฐ์ ๋ getParameter
02์์ 03์ผ๋ก ๋๊ฒจ๋ฐ์ ๋ getParmeter ์ getAttribute ๋ก ์ธ์
ํ์ฉ
01์์ 03์ผ๋ก ์ง์ ๋๊ฒจ์ค ์ ์๊ธฐ ๋๋ฌธ์ ์ธ์
(session)์ ์ ์ฅ
โป session ์ธ์ input ํ๊ทธ hidden ์์ฑ์ ์ด์ฉํ ์ ๋ณด ์ ๋ฌ ๊ฐ๋ฅ~!!!
-->
<div>
<!-- <h1>TestSession01.jsp -> TestSession02.jsp -> TestSession03.jsp</h1> -->
<h2>ํ์๊ฐ์
01 (์ด๋ฆ, ์ ํ๋ฒํธ)</h2>
<h2>(TestSession01.jsp)</h2>
<hr>
</div>
<div class="layout">
<div class="tbl_box">
<form action="TestSession02.jsp" method="post" name="form01">
<table>
<tr>
<th>์ด๋ฆ</th>
<td><input type="text" id="userName" name="userName"></td>
</tr>
<tr>
<th>์ ํ</th>
<td><input type="text" id="userTel" name="userTel"></td>
</tr>
<tr class="btn_box" style="display: contents;">
<td colspan="2">
<a href="javascript:formCheck01();"><button type="button" style="width: 100%;">์
๋ ฅ</button></a>
</td>
</tr>
</table>
</form>
</div>
</div>
<script type="text/javascript">
function formCheck01()
{
//alert("ํ์ธ");
var f = document.form01;
if(!f.userName.value)
{
alert("์ด๋ฆ์ ์
๋ ฅํด์ฃผ์ธ์.");
f.userName.focus();
return;
}
if(!f.userTel.value)
{
alert("์ ํ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.");
f.userTel.focus();
return;
}
f.submit();
}
</script>
</body>
</html>
ใดใดTestSession02.jsp_ํ์๊ฐ์ 02 (์์ด๋, ํจ์ค์๋)
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// ์ด์ ํ์ด์ง(TestSession01.jsp)๋ก ๋ถํฐ ๋์ด์จ ๋ฐ์ดํฐ ์์
// -> userName, userTel
request.setCharacterEncoding("UTF-8");
String name = request.getParameter("userName");
String tel = request.getParameter("userTel");
// check~!!
// ์ถ๊ฐ
// ์ธ์ ์ผ๋ก ๊ฐ ๋ณด๋ด๊ธฐ
session.setAttribute("userName", name);
session.setAttribute("userTel", tel);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSession02.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h2>ํ์๊ฐ์
02 (์์ด๋, ํจ์ค์๋)</h2>
<h2>(TestSession02.jsp)</h2>
<hr>
</div>
<div class="layout">
<div class="tbl_box">
<form action="TestSession03.jsp" method="post" name="form02">
<table>
<tr>
<th>์์ด๋</th>
<td><input type="text" id="userId" name="userId"></td>
</tr>
<tr>
<th>ํจ์ค์๋</th>
<td><input type="text" id="userPwd" name="userPwd"></td>
</tr>
<tr class="btn_box" style="display: contents;">
<td colspan="2">
<a href="javascript:formCheck02();"><button type="button" style="width: 100%;">์
๋ ฅ</button></a>
</td>
</tr>
</table>
<%-- <input type="text" id="userName" name="userName" value="<%=name%>">
<input type="text" id="userTel" name="userTel" value="<%=tel%>"> --%>
</form>
</div>
</div>
<script type="text/javascript">
function formCheck02()
{
//alert("ํ์ธ");
var f = document.form02;
if(!f.userId.value)
{
alert("์์ด๋๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.");
f.userName.focus();
return;
}
if(!f.userPwd.value)
{
alert("์ ํ๋ฒํธ๋ฅผ ์
๋ ฅํด์ฃผ์ธ์.");
f.userPwd.focus();
return;
}
f.submit();
}
</script>
</body>
</html>
ใดใดTestSession03.jsp_์ด๋ฆ, ์ ํ๋ฒํธ, ์์ด๋, ํจ์ค์๋ ์ถ๋ ฅ
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// ์ด์ ํ์ด์ง(TestSession02.jsp)๋ก ๋ถํฐ ๋์ด์จ ๋ฐ์ดํฐ ์์
// -> userId, userPwd
request.setCharacterEncoding("UTF-8");
String id = request.getParameter("userId");
String pwd = request.getParameter("userPwd");
//String name = request.getParameter("userName");
//String tel = request.getParameter("userTel");
// ์ธ์
์์ ๊ฐ ๊ฐ์ ธ์ค๊ธฐ
String name = (String)session.getAttribute("userName");
String tel = (String)session.getAttribute("userTel");
session.removeAttribute("userName");
session.removeAttribute("userTel");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSession03.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h2>์ด๋ฆ, ์ ํ๋ฒํธ, ์์ด๋, ํจ์ค์๋ ์ถ๋ ฅ</h2>
<h2>(TestSession03.jsp)</h2>
<hr>
</div>
<div class="layout">
<div class="tbl_box">
<form action="TestSession03.jsp" method="post" name="form02">
<table>
<tr>
<th>์ด๋ฆ</th>
<td><%=name %></td>
</tr>
<tr>
<th>์ ํ</th>
<td><%=tel %></td>
</tr>
<tr>
<th>์์ด๋</th>
<td><%=id%></td>
</tr>
<tr>
<th>ํจ์ค์๋</th>
<td><%=pwd%></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
F_WebApp15: ์ฟ ํค ์ค์ ๋ฐ ์ถ๊ฐ, ์ฟ ํค ์ ๋ณด ์ป์ด๋ด๊ธฐ, ์ฟ ํค ์ ๋ณด ์ญ์ / Application์ ํ์ฉํ ์ ์์ ์ ์ฒดํฌ
ใด/WebApp15/WebContent




ใดใดTestSetCookie.jsp_์ฟ ํค ์ ๋ณด ์ป์ด๋ด๊ธฐ
<%@ page contentType="text/html; charset=UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
Cookie[] ck = request.getCookies();
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestGetCookie.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h1>์ฟ ํค ์ ๋ณด ์ป์ด๋ด๊ธฐ</h1>
<hr>
</div>
<div class="layout">
<div class="tbl_box">
<table class="table">
<tr>
<th style="width: 120px;">์ฟ ํค ์ด๋ฆ</th>
<th>์ฟ ํค ๊ฐ</th>
</tr>
<%
for (Cookie c : ck)
{
%>
<tr>
<td><%= c.getName() %></td>
<td><%= c.getValue() %></td>
</tr>
<%
}
%>
</table>
</div>
<div class="layout">
<a href="TestSetCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ์ค์ </button></a>
<a href="TestRemoveCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ์ญ์ </button></a>
</div>
</div>
</body>
</html>
ใดใดTestRemoveCookie.jsp_์ฟ ํค ์ ๋ณด ์ญ์ ํ๊ธฐ
<%@ page contentType="text/html; charset=UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
/* **
์ฟ ํค๋ ์ ๊ฑฐ๊ฐ ๋ฐ๋ก ์์. -> ๋น์ด์๋ ์ฟ ํค๋ก ๋ฎ์ด์
** */
// ๋น์ด์๋ ๋ด์ฉ์ผ๋ก ๊ธฐ์กด์ ์ฟ ํค๋ฅผ ๋ฎ์ด์ฐ๊ธฐํ๋ ๊ฐ๋
Cookie killCookie = new Cookie("cookie_test", ""); // ์ ๊ฑฐ ํ๊ณ ์ ํ๋ ์ฟ ํค ์ด๋ฆ๊ณผ ๊ฐ์์ผ ํจ
killCookie.setMaxAge(0);
response.addCookie(killCookie);
// ์ฒ์ ์ฟ ํค๋ฅผ ๊ตฌ์ฑํ ๋์๋ ใaddCookie()ใ๋ก ์ฒ๋ฆฌํ์๊ธฐ ๋๋ฌธ์
// ์ญ์ ํ ใฑ๋๋ ๊ฐ์ ์ด๋ฆ์ ์ฟ ํค๋ฅผ ใaddCookie()ใ๋ก ์ฒ๋ฆฌํด์ผ ์์ ์ ์ผ๋ก ์ญ์ .
// ์ฆ, ๋ด์ฉ์ด ํฌํจ๋ ์ฟ ํค๋ฅผ ์ฌ์๋ค๊ฐ..
// ์ด๋ฒ์๋ ๋ด์ฉ์ด ๋น์ด์๋ ์ฟ ํค๋ฅผ ์ฌ๋ ๊ฐ๋
.
//โป ์ฌ๊ธฐ์ ์ฟ ํค ์ญ์ ๋ ํด๋ผ์ด์ธํธ ์
์ฅ์์์ ์ญ์ ์ด๋ค.
// ํ ๋ช
์ ํด๋ผ์ด์ธํธ๊ฐ ์ฟ ํค๋ฅผ ์ญ์ ํ๋ค๊ณ ํด์
// ๋ค๋ฅธ ํด๋ผ์ด์ธํธ๋ค์ ์ฟ ํค๋ ์ญ์ ๋๋ฉด ์๋๊ธฐ ๋๋ฌธ์
// ์ด ์ฟ ํค์ ์ ๋ณด๋ ๋ก์ปฌ PC์์ ์ปจํธ๋กค ํ๊ฒ ๋๋ค.(๋ธ๋ผ์ฐ์ ๊ฐ...)
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestRemoveCookie.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h1>์ฟ ํค ์ ๋ณด ์ญ์ ํ๊ธฐ</h1>
<hr>
</div>
<div class="layout">
<h2>์ฑ๊ณต์ ์ผ๋ก ์ฟ ํค๋ฅผ ์ ๊ฑฐํ์ต๋๋ค~!!!</h2>
<div class="btn_box">
<a href="TestSetCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ์ค์ </button></a>
<a href="TestGetCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ํ์ธ</button></a>
</div>
</div>
</body>
</html>
ใดใดTestSetCookie.jsp_์ฟ ํค ์ค์ ๋ฐ ์ถ๊ฐ
<%@ page contentType="text/html; charset=UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
// ์ฟ ํค ์์ฑ(์๋ฒ์ ์์ฑ๋ ์ฟ ํค)
Cookie c = new Cookie("cookie_test", "studyCookie");
/* **์ฟ ํค๋ ์๋ธ๋ฆฟ์ปจํ
์ด๋(์๋ฒ)์ ๋ง๋ค์ด์ง** */
// ์ฟ ํค ์ค์ (์๋ฒ์ ์์ฑ๋ ์ฟ ํค์ ๋ํ ์ค์ )
c.setMaxAge(3600); // ์ฟ ํค 1์๊ฐ ์ ์ง
// ์ฟ ํค ์ถ๊ฐ (์๋ฒ์์ ์์ฑ๋๊ณ ์ค์ ๋ ์ฟ ํค๋ฅผ ํด๋ผ์ด์ธํธ์ ์ ๋ฌ(์ฌ๊ธฐ))
response.addCookie(c);
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestSetCookie.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h1>์ฟ ํค ์ค์ ๋ฐ ์ถ๊ฐ</h1>
<hr>
</div>
<div class="layout">
<div class="btn_box">
<a href="TestGetCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ํ์ธ</button></a>
<a href="TestRemoveCookie.jsp"><button type="button" class="btn">์ฟ ํค ์ ๋ณด ์ญ์ </button></a>
</div>
</div>
</body>
</html>

ใดใด TestApplication.jsp_Application์ ํ์ฉํ ์ ์์ ์ ์ฒดํฌ
<%@ page contentType="text/html; charset=UTF-8"%>
<%
// ์ ์์ ์
int n = 0;
String count =(String)application.getAttribute("count");
if(count != null)
n = Integer.parseInt(count);
n++;
application.setAttribute("count", Integer.toString(n));
String realPath = application.getRealPath("/");
application.log("์ ์์: "+request.getRemoteAddr());
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>TestApplication.jsp</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h1>Application์ ํ์ฉํ ์ ์์ ์ ์ฒดํฌ</h1>
<hr>
</div>
<div class="layout">
<h2>์ด ์ ์์: <%=n %></h2>
<h2 style="word-wrap:break-word;">์น ์๋ฒ ์ค์ ๊ฒฝ๋ก<%=realPath %></h2>
</div>
</body>
</html>
โ โ โ Emmet(์๋ฐ) โ โ โ
/* ** html ์์ฐ์ฑ ํฅ์ ๋๊ตฌ** */
โ ๊ฐ์
- ๊ธฐ์กด์๋ Zen Coding(์ ์ฝ๋ฉ) ์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ์ฌ์ฉ๋์๋ค.
- ์ดํ... Goolge์์ ์ด ๋๊ตฌ๋ฅผ ์์ฉํ๋ฉด์ emmet ์ด๋ผ๋ ์ด๋ฆ์ผ๋ก ๋ณ๊ฒฝ๋์๋ค.
- HTML ์์ฐ์ฑ ํฅ์ ๋๊ตฌ(HTML ์ฝ๋ฉ์ ๋น ๋ฅด๊ฒ ํ๊ธฐ ์ํ ํ๋ฌ๊ทธ์ธ)
- CSS ์ ํ์ ์ฌ์ฉ(CSS3 ์ง์)
-> HTML ์ CSS ์ ํ์๋ฅผ ํตํด ๊ฒ์ํ๋ ๋ฐฉ๋ฒ ๋์
CSS ์ ํ์๋ฅผ ํตํด HTML ์ ์์ฑํ๋๋ก ํ๋ ๊ฐ๋
.
โ ํ๊ฒฝ ์ค์
- ๋๋ถ๋ถ์ ํด์์ ์ง์ํ๊ณ ์์
(โป ๊ทธ๋ฆฌ๊ณ ๋๋ถ๋ถ์ ํธ์ง๊ธฐ ๋ด์์์ ์ก์
ํค: Ctrl + E)
โ ๋ฉ์ธ ํ์ด์ง ์ข์ธก์ ์๋ Download ๋ฉ๋ด ํด๋ฆญ
-> https://emmet.io/download/ ํ์ด์ง๋ก ์ด๋
โก Download ๋ฆฌ์คํธ๋ค ์ค ๋ณธ์ธ์ด ์ฌ์ฉํ ํธ์งํด์ ๋ฉ๋ด ํด๋ฆญ
โข Installation ํญ๋ชฉ์์ ์ ์ํ ์์๋๋ก ์งํ
โป ํน์ด์ฌํญ
Emmet ํ๋ฌ๊ทธ์ธ ์ค์น ์ดํ ์ดํด๋ฆฝ์ค ๊ธฐ๋ณธ ๋จ์ถํค์ ์ค๋ณต๋๋ ํญ๋ชฉ์ด ์กด์ฌํจ.
------------------
Ctrl + D
==> ๋จ์ถํค ์ฌ์ค์
(์ดํด๋ฆฝ์ค > ์๋์ฐ > ์ค์ > General > keys)
F_EmmetApp
ใด/EmmetApp/WebContent
ใดใดEmmetTest01.html_โป ๊ธฐ๋ฅ ์ ์ฉ ์ก์ ํค -> Ctrl + E
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>EmmetTest01.html</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body class="section">
<div>
<h1>โป ๊ธฐ๋ฅ ์ ์ฉ ์ก์
ํค -> Ctrl + E</h1>
<hr>
</div>
<div class="layout">
<ul>
<li>
<h2>1. ํ๊ทธ ์ ํ์</h2>
div
<xmp>
<div></div>
</xmp>
div{๋ฃ์๋ด์ฉ}
<xmp>
<div>๋ฃ์๋ด์ฉ</div>
</xmp>
<h3>emmet์ผ๋ก ๋ง๋ค๊ณ ์์ฑ๊ฐ ์ฌ์ด๋ฅผ 'tab'์ผ๋ก ์ด๋๊ฐ๋ฅ</h3>
a
<a href="http://www.naver.com">๋ค์ด๋ฒ</a>
img
<xmp><img src="" alt="" /></xmp>
table
<xmp>
<table></table>
</xmp>
span
<xmp><span></span></xmp>
p
<xmp>
<p></p>
</xmp>
</li>
<li>
<h2>2. ์์ด๋ ์ ํ์</h2>
div#box
<xmp>
<div id="box"></div>
</xmp>
div#box{kkk}
<xmp>
<div id="box">kkk</div>
</xmp>
div#box.happy{kkk}
<xmp>
<div id="box" class="happy">kkk</div>
</xmp>
<h3>-> div๋ ๋ณ๋์ ์์ฑ์์ด๋ div๋ก ๊ตฌ์ฑ๋จ</h3>
#box
<xmp>
<div id="box"></div>
</xmp>
#box{1234}
<xmp>
<div id="box">1234</div>
</xmp>
</li>
<li>
<h2>3. ํด๋์ค ์ ํ์</h2>
div.items
<xmp>
<div class="items"></div>
</xmp>
div.items{aaa}
<xmp>
<div class="items">aaa</div>
</xmp>
.items
<xmp>
<div class="items"></div>
</xmp>
.items{bbb}
<xmp>
<div class="items">bbb</div>
</xmp>
</li>
<li>
<h2>4. ์กฐํฉ</h2>
div#box.items
<xmp>
<div id="box" class="items"></div>
</xmp>
div#box.items.unit.control
<xmp>
<div id="box" class="items unit control"></div>
</xmp>
div#box.items.unit{aaa}
<xmp>
<div id="box" class="items unit">aaa</div>
</xmp>
div.items.unit{bbb}
<xmp>
<div class="items unit">bbb</div>
</xmp>
</li>
<li>
<h2>5. ์์ฑ ์ ํ์</h2>
div[title]
<xmp>
<div title=""></div>
</xmp>
div[title='test']
<xmp>
<div title="test"></div>
</xmp>
a[href='www.naver.com' title='๋ค์ด๋ฒ']
<xmp><a href="www.naver.com" title="๋ค์ด๋ฒ"></a></xmp>
a[href='www.naver.com' title='๋ค์ด๋ฒ']{์ฌ์ดํธ๋ก ์ด๋}
<xmp><a href="www.naver.com" title="๋ค์ด๋ฒ">์ฌ์ดํธ๋ก ์ด๋</a></xmp>
</li>
<li>
<h2>6. PCDATA</h2>
div{๋ฐ์ค}
<xmp>
<div>๋ฐ์ค</div>
</xmp>
a{ํํ์ด์ง๋ก ์ด๋}
<xmp><a href="">ํํ์ด์ง๋ก ์ด๋</a></xmp>
p{๋ฌธ๋จ๋ด์ฉ๊ธฐ์ }
<xmp>
<p>๋ฌธ๋จ๋ด์ฉ๊ธฐ์ </p>
</xmp>
</li>
<li>
<h2>๋ฐ๋ณต ์์ฑ</h2>
div*5
<xmp>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</xmp>
img[src=images/dog.jpg]*5
<xmp>
<img src="images/dog.jpg" alt="" />
<img src="images/dog.jpg" alt="" />
<img src="images/dog.jpg" alt="" />
<img src="images/dog.jpg" alt="" />
<img src="images/dog.jpg" alt="" />
</xmp>
.box*5
<xmp>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
<div class="box"></div>
</xmp>
.box{content}*5
<xmp>
<div class="box">content</div>
<div class="box">content</div>
<div class="box">content</div>
<div class="box">content</div>
<div class="box">content</div>
</xmp>
<h3>$ -> ํญ๋ชฉ ๋ฒํธ ๋งค๊ธฐ๊ธฐ</h3>
#box$.box{content}*5
<xmp>
<div id="box1" class="box">content</div>
<div id="box2" class="box">content</div>
<div id="box3" class="box">content</div>
<div id="box4" class="box">content</div>
<div id="box5" class="box">content</div>
</xmp>
img[src=images.obj$.jpg]*5
<xmp>
<img src="images.obj1.jpg" alt="" />
<img src="images.obj2.jpg" alt="" />
<img src="images.obj3.jpg" alt="" />
<img src="images.obj4.jpg" alt="" />
<img src="images.obj5.jpg" alt="" />
</xmp>
h1*6
<xmp>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
<h1></h1>
</xmp>
h$*6
<xmp>
<h1></h1>
<h2></h2>
<h3></h3>
<h4></h4>
<h5></h5>
<h6></h6>
</xmp>
h${์ ๋ชฉ$}*6
<xmp>
<h1>์ ๋ชฉ1</h1>
<h2>์ ๋ชฉ2</h2>
<h3>์ ๋ชฉ3</h3>
<h4>์ ๋ชฉ4</h4>
<h5>์ ๋ชฉ5</h5>
<h6>์ ๋ชฉ6</h6>
</xmp>
</li>
<li>
<h2>8. ์ฐ์ ์์ฑ</h2>
div+p
<xmp>
<div></div>
<p></p>
</xmp>
h1{์ ๋ชฉ}+p{๋ด์ฉ}*5
<xmp>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
</xmp>
(h1{์ ๋ชฉ}+p{๋ด์ฉ}*2)*5
<xmp>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
<h1>์ ๋ชฉ</h1>
<p>๋ด์ฉ</p>
<p>๋ด์ฉ</p>
</xmp>
div+a+div+p+div+img
<xmp>
<div></div>
<a href=""></a>
<div></div>
<p></p>
<div></div>
<img src="" alt="" />
</xmp>
</li>
<li>
<h2>9. ํ์ ์์ฑ</h2>
table+
<xmp>
<table>
<tr>
<td></td>
</tr>
</table>
</xmp>
ul+
<xmp>
<ul>
<li></li>
</ul>
</xmp>
ol+
<xmp>
<ol>
<li></li>
</ol>
</xmp>
select+
<xmp><select name="" id="">
<option value=""></option>
</select></xmp>
</li>
<li>
<h2>10. ์์์์ฑ</h2>
div>p
<xmp>
<div>
<p></p>
</div>
</xmp>
div>p*5
<xmp>
<div>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</div>
</xmp>
(div>p*2)*5
<xmp>
<div>
<p></p>
<p></p>
</div>
<div>
<p></p>
<p></p>
</div>
<div>
<p></p>
<p></p>
</div>
<div>
<p></p>
<p></p>
</div>
<div>
<p></p>
<p></p>
</div>
</xmp>
table#tbl>tr*5>td*3
<xmp>
<table id="tbl">
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</xmp>
table#tbl>tr*3>td.label+td.content
<xmp>
<table id="tbl">
<tr>
<td class="label"></td>
<td class="content"></td>
</tr>
<tr>
<td class="label"></td>
<td class="content"></td>
</tr>
<tr>
<td class="label"></td>
<td class="content"></td>
</tr>
</table>
</xmp>
table#tbl>tr*3>td#label$+td.content
<xmp>
<table id="tbl">
<tr>
<td id="label1"></td>
<td class="content"></td>
</tr>
<tr>
<td id="label2"></td>
<td class="content"></td>
</tr>
<tr>
<td id="label3"></td>
<td class="content"></td>
</tr>
</table>
</xmp>
table#tbl>(tr>th*3)+((tr>td*3)*5)
<xmp>
<table id="tbl">
<tr>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</xmp>
</li>
<li>
<h2>11. ๋๋ฏธ ํค์๋</h2>
lorem
<xmp>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Saepe quaerat modi totam temporibus voluptas vero exercitationem voluptate alias facilis quis quia deserunt adipisci debitis cumque maiores. Minus aliquam doloribus dolore.
</xmp>
<h3>lorem์ ํ๊ทธ์ฌ์ด์ ๋ฃ์ผ๋ฉด ์คํ๋์ง ์์</h3>
<p>ใด ๋ฐฉ๋ฒ1) lorem๋ค์ ์ปค์๋๊ณ ์คํ</p>
table>(tr>th*2)+(tr>(td{word}+td{lorem}))*3
<xmp>
<table>
<tr>
<th></th>
<th></th>
</tr>
<tr>
<td>word</td>
<td>lorem</td>
</tr>
<tr>
<td>word</td>
<td>lorem</td>
</tr>
<tr>
<td>word</td>
<td>lorem</td>
</tr>
</table>
</xmp>
<p>ใดlorem์ ํจ์์ฒ๋ผ ์ฌ์ฉ</p>
table>(tr>th*2)+(tr>(td{word}+lorem(td{desc})))*3
<xmp>
<table>
<tr>
<th></th>
<th></th>
</tr>
<tr>
<td>word</td>
<td>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Obcaecati exercitationem sed enim nam tempora aperiam magni aut. Minus eos beatae odio officia expedita fugit nesciunt molestiae eveniet error amet repellendus.</td>
</tr>
<tr>
<td>word</td>
<td>Optio dignissimos ipsa distinctio aperiam odit non ut repellendus odio maxime debitis nulla quos quisquam unde aliquam molestias consequatur ipsam perspiciatis consectetur omnis incidunt officiis eum vitae temporibus atque fuga.</td>
</tr>
<tr>
<td>word</td>
<td>Exercitationem tenetur voluptatibus non quam earum eveniet omnis soluta quibusdam dolorem sunt facilis esse incidunt inventore corporis nihil repudiandae at itaque quia officia provident tempore ea ad et ex commodi!</td>
</tr>
</table>
</xmp>
</li>
</ul>
</div>
</body>
</html>
ใดใดEmmetTest02.html_์ค์ต 1~3
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<!-- <link rel="stylesheet" type="text/css" href="css/main.css"> -->
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<h2>์ค์ต1</h2>
h1#title.blue{Emmet}+(h2.subtitle{์์ ๋ชฉ}+p.content{๋ด์ฉ})*5
<xmp>
<h1 id="title" class="blue">Emmet</h1>
<h2 class="subtitle">์์ ๋ชฉ</h2>
<p class="content">๋ด์ฉ</p>
<h2 class="subtitle">์์ ๋ชฉ</h2>
<p class="content">๋ด์ฉ</p>
<h2 class="subtitle">์์ ๋ชฉ</h2>
<p class="content">๋ด์ฉ</p>
<h2 class="subtitle">์์ ๋ชฉ</h2>
<p class="content">๋ด์ฉ</p>
<h2 class="subtitle">์์ ๋ชฉ</h2>
<p class="content">๋ด์ฉ</p>
</xmp>
<h2>์ค์ต2</h2>
table>(tr.line>(td.col{๋ด์ฉ$}+td.comm{๋ถ์ฐ์ค๋ช
})*3)*3
table>tr.line*3>((td.col{๋ด์ฉ$})*3(td.comm{๋ถ์ฐ์ค๋ช
}))
<table>
<tr class="line">
<td class="col">๋ด์ฉ1</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
<tr class="line">
<td class="col">๋ด์ฉ2</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
<tr class="line">
<td class="col">๋ด์ฉ3</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
</table>
<xmp>
<table>
<tr class="line">
<td class="col">๋ด์ฉ1</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ2</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ3</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
<tr class="line">
<td class="col">๋ด์ฉ1</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ2</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ3</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
<tr class="line">
<td class="col">๋ด์ฉ1</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ2</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
<td class="col">๋ด์ฉ3</td>
<td class="comm">๋ถ์ฐ์ค๋ช
</td>
</tr>
</table>
</xmp>
<h2>์ค์ต3</h2>
table#table>tr#line1*2>th#head${ํญ๋ชฉ$}+td.col{๋ด์ฉ$}*3
<table id="table">
<tr id="line1">
<th id="head1">ํญ๋ชฉ1</th>
<td class="col">๋ด์ฉ1</td>
<td class="col">๋ด์ฉ2</td>
<td class="col">๋ด์ฉ3</td>
</tr>
<tr id="line1">
<th id="head2">ํญ๋ชฉ2</th>
<td class="col">๋ด์ฉ1</td>
<td class="col">๋ด์ฉ2</td>
<td class="col">๋ด์ฉ3</td>
</tr>
</table>
</body>
</html>
#์๊ฐํด ๋ณผ ๊ฒ
- ํ์ด๋ ํ๋ก์ ํธ
ใด์ฃผ์ ๊ณ ๋ฏผ
ใด ์ด๋ป๊ฒ ๋ง๋ค์ง ๊ณ ๋ฏผํด๋ณด๊ธฐ
ใด ์ด๋ค ํํธ๋ก ๋๋ ์ ํ ์ง.. ๋ถ์กฑํ ๋ถ๋ถ ๊ณต๋ถํ๊ธฐ
- 2/19๋ถํฐ ํ์ด๋ ํ๋ก์ ํธ ์งํํ์