java

JSP - ๊ฐœ๋…์ •๋ฆฌ

dev_summer 2020. 11. 9. 15:19

 

* ์„ธ์…˜

- ์„ธ์…˜์€ ์‚ฌ์šฉ์žํŽ˜์ด์ง€์—์„œ ์•ˆ๋ณด์ด๊ณ  ์„œ๋ฒ„๊ฐ€ ๋“ค๊ณ ์žˆ๋Š” ๋ฐ์ดํ„ฐ, ๋ฆฌํ€˜์ŠคํŠธ ์•ˆ์— ์ €์žฅ๋œ๋‹ค.

- ํ†ฐ์บฃ ๋‚ด์— ์„ธ์…˜์ปจํ…์ŠคํŠธ์— key, value,๋“ค์–ด์˜ค๋Š” ์Šค๋ ˆ๋“œ(์‚ฌ์šฉ์ž)๋งˆ๋‹ค ๊ด€๋ฆฌ ๋œ๋‹ค.

 

 

* JSP์—์„œ๋Š” out์ด ๋‚ด์žฅ๊ฐ์ฒด์ด์ง€๋งŒ, java์—์„œ๋Š” out์ด ๋‚ด์žฅ๊ฐ์ฒด๊ฐ€ ์•„๋‹ˆ๊ธฐ๋•Œ๋ฌธ์— JAVA์—์„œ ์“ธ๋• printWriter๋กœ ์‚ฌ์šฉํ•˜์—ฌ stream์— ์ ‘๊ทผํ•œ๋‹ค.

PrintWriter out = response.getWriter();

out.print("<script>"); ํ˜•์‹์œผ๋กœ ๋„˜๊ฒจ์ค˜์•ผํ•œ๋‹ค

 

 

* request์˜ ์žฌํ™œ์šฉ

- request์˜ ์žฌํ™œ์šฉ์€ ์„œ๋ฒ„์—์„œ๋งŒ ํ• ์ˆ˜์žˆ๋‹ค. ์‚ฌ์šฉ์ž๋Š” ์žฌ์‚ฌ์šฉ ํ• ์ˆ˜ ์—†๋‹ค.

- ํ†ฐ์บฃ์€ ํ•ญ์ƒ ์ƒˆ๋กœ์šด request, response๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. requestDispatcher๋ฅผ ์ด์šฉํ•˜๋ฉด ์ƒˆ๋กœ์ƒ์„ฑ๋œ request, response์— ์ƒˆ๋กœ ๋ฎ์–ด๋ฒ„๋ฆฐ๋‹ค.

 

 

*include

- ํƒฌํ”Œ๋ฆฟ

- ๋“ค๊ณ ์™€์„œ ์ปดํŒŒ์ผ ํ•จ

 

* response.sendRedirect();

- ํŽ˜์ด์ง€ ์ด๋™ ์‹œ ์‚ฌ์šฉ

 

* out.print

bufferedWirter

๋‚ด๋ ค์“ฐ๊ธฐ๊ฐ€ ์ž‡๊ณ  ์—†๊ณ ์˜ ์ฐจ์ด

 

* request๋Š” session์ด ๋“ค๊ณ  ์žˆ์Œ.

response๋Š” out์„ ๊ฐ–๊ณ  ์ž‡์Œ.

 

* ์ฟ ํ‚ค์™€ ์Šคํ† ๋ฆฌ์ง€(๋ธŒ๋ผ์šฐ์ €์˜ ๊ฐœ๋ฐœ์ž๋ชจ๋“œ->appldiction)

์บ์‹œ๋Š” ์ž„์‹œ์ €์žฅ์†Œ,

์ฟ ํ‚ค๋Š” ๋ณด์•ˆ์— ๋ฏผ๊ฐํ•˜์ง€์•Š์€ ์ž„์‹œ๊ธฐ์–ต๋ฐ์ดํ„ฐ๋ฅผ ์ €์žฅํ•˜๋Š” ๊ณณ์œผ๋กœ 4kb๊นŒ์ง€ ๋ฐ–์— ์ €์žฅ์ด ๋˜์ง€์•Š์•„ ์Šคํ† ๋ฆฌ์ง€(์ตœ๋Œ€ 5mb)๊ฐ€ ๋“ฑ์žฅํ•˜์˜€๋‹ค. ๋…ธ์ถœ์ด ๋˜๋„ ๊ดœ์ฐฎ์€ ์ •๋ณด๋“ค์„ ์ €์žฅํ•˜๋Š” ๊ณณ์ด๋ฉฐ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ๋ˆ„๊ตฌ๋‚˜ ์ ‘๊ทผ์ด ๊ฐ€๋Šฅํ•˜๋ฉฐ key,value ํ˜•ํƒœ๋กœ get,set ๊ฐ€๋Šฅํ•˜๋‹ค. ex)localStorage.setItem('phone','010-2222');

๋กœ์ปฌ์Šคํ† ๋ฆฌ์ง€๋Š” ํ•ด๋‹น์ฃผ์†Œ์—์„œ๋งŒ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•˜๋ฉฐ ์„ธ์…˜์Šคํ† ๋ฆฌ์ง€๋Š” ๋ธŒ๋ผ์šฐ์ €์ฐฝ์ด ๋‹ซํžˆ๊ธฐ ์ „๊นŒ์ง€ ์‚ฌ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

์ฟ ํ‚ค์™€ ์Šคํ† ๋ฆฌ์ง€ ๋‘˜๋‹ค ์„œ๋ฒ„๊ฐ€ ๋งŒ๋“ค์ง€๋งŒ ์ฟ ํ‚ค๋Š” ์†์„ฑ์„ ์ค„ ์ˆ˜ ์žˆ๋‹ค. httponly์†์„ฑ์„ ์ฃผ๋ฉด ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ๋กœ ์ ‘๊ทผ์ด ๋ถˆ๊ฐ€ํ•˜๊ธฐ๋•Œ๋ฌธ์— ๋ณด์•ˆ์— ์œ ๋ฆฌํ•˜๋‹ค.

์„œ๋ฒ„๋Š” responseํ• ๋•Œ jsessionid๋ฅผ ๋‹ด์•„์„œ ์‘๋‹ตํ•ด์ค€๋‹ค. ์„œ๋ฒ„๊ฐ€ ๋˜์ง„ jsessionid๋Š” ์ธ์ฆ์ด ์•„๋‹Œ ๊ตฌ๋ถ„์„ ์œ„ํ•ด ์‚ฌ์šฉ์ด ๋˜๋ฉฐ ์ธ์ฆํ• ๋•Œ๋Š” key, value๊ฐ’์ด ํ•„์š”ํ•˜๋‹ค. ํด๋ผ์ด์–ธํŠธ๋„ requestํ• ๋•Œ jsessionid๋ฅผ ๋˜์ ธ ์„ธ์…˜์ด ์œ ํšจํ•จ์„ ๊ตฌ๋ถ„ํ•œ๋‹ค. ์ด jsessionid๋Š” n๋ถ„๋™์•ˆ requestํ•˜์ง€์•Š์œผ๋ฉด ์„ธ์…˜์€ ์ž๋™์œผ๋กœ ์‚ฌ๋ผ์ง€๋Š”๋ฐ Servers์˜ web.xml์— session-timout์„ค์ •์—์„œ ์„ค์ • ๊ฐ€๋Šฅํ•˜๋‹ค.

 

'java' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

MVCํŒจํ„ด  (0) 2020.11.09
JAVA - Exception ์ข…๋ฅ˜  (0) 2020.11.09
jsp - include  (0) 2020.10.30
jsp- request๊ฐ์ฒด  (0) 2020.10.30
jsp ๋‚ด์žฅ๊ฐ์ฒด ์ด์šฉํ•˜๊ธฐ  (0) 2020.10.30