[JSP/Servlet] Request, Response ๊ฐ์ฒด

Request, Response

  • ์„œ๋ธ”๋ฆฟ์€ ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ ์ •๋ณด๋ฅผ Request ๊ฐ์ฒด์— ๋‹ด๊ณ , ์š”์ฒญ์— ๋Œ€ํ•œ ์‘๋‹ต ์ •๋ณด๋ฅผ Reponse ๊ฐ์ฒด์— ๋‹ด๋Š”๋‹ค.

HttpServletRequest

  • HTTP ํ”„๋กœํ† ์ฝœ์˜ Request ์ •๋ณด๋ฅผ ์„œ๋ธ”๋ฆฟ์—๊ฒŒ ์ „๋‹ฌํ•˜๊ธฐ ์œ„ํ•ด WAS๊ฐ€ ์ƒ์„ฑ

  • ์š”์ฒญํ•˜๊ธฐ ์œ„ํ•ด ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๋ชจ๋“  ์ •๋ณด๋ฅผ ๋ชจ๋‘ ๋ฉ”์„œ๋“œ๋กœ ๋‹ด์Œ

  • ํ—ค๋” ์ •๋ณด, ํŒŒ๋ผ๋ฏธํ„ฐ, ์ฟ ํ‚ค, URI, URL .. ๋“ฑ์„ ์ฝ๊ธฐ ์œ„ํ•œ ๋ฉ”์„œ๋“œ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์Œ

HttpServletResponse

  • ์‘๋‹ต์„ ๋ณด๋‚ด๊ธฐ ์œ„ํ•ด WAS๊ฐ€ HttpServletResponse ๊ฐ์ฒด๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์„œ๋ธ”๋ฆฟ์—๊ฒŒ ์ „๋‹ฌ

  • ์‘๋‹ต ์ฝ”๋“œ, ์‘๋‹ต ๋ฉ”์‹œ์ง€ ๋“ฑ์„ ์ „์†ก

๊ฐ์ฒด ์ƒ์„ฑ ๋ฐ ์‚ฌ์šฉ ๊ณผ์ •

  • ์›น๋ธŒ๋ผ์šฐ์ €์—์„œ URL์„ ์ž…๋ ฅํ•œ๋‹ค.

  • ํด๋ผ์ด์–ธํŠธ๋Š” ๋„๋ฉ”์ธ๊ณผ ํฌํŠธ ๋ฒˆํ˜ธ๋กœ ์„œ๋ฒ„์— ์ ‘์†๋œ๋‹ค.
  • ํด๋ผ์ด์–ธํŠธ์˜ IP, path ์ •๋ณด ๋“ฑ ์—ฌ๋Ÿฌ ๊ฐ€์ง€ ์ •๋ณด๋“ค์ด ์„œ๋ฒ„์— ์ „์†ก๋œ๋‹ค.

  • ํด๋ผ์ด์–ธํŠธ๋กœ๋ถ€ํ„ฐ ์š”์ฒญ์ด ๋“ค์–ด์˜ค๋ฉด WAS๋Š” HttpServletRequest, HttpServletResponse ์ƒ์„ฑ

  • HttpServletRequest -> ์š”์ฒญ ์‹œ ๊ฐ€์ ธ์˜จ ์ •๋ณด๋ฅผ ๊ฐ์ฒด์— ๋‹ด์Œ

  • HttpServletResponse -> ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „์†กํ•˜๊ธฐ ์œ„ํ•œ ์ •๋ณด๋ฅผ ๊ฐ์ฒด์— ๋‹ด์Œ

  • ์š”์ฒญ ์ •๋ณด์— ์žˆ๋Š” path๋กœ ๋งคํ•‘๋œ ์„œ๋ธ”๋ฆฟ์—๊ฒŒ ๊ฐ์ฒด๋“ค์ด ์ „๋‹ฌ

  • doPost(),service() ๋“ฑ์˜ ๋ฉ”์„œ๋“œ์— ํŒŒ๋ผ๋ฏธํ„ฐ๋กœ ์ „๋‹ฌ๋˜์–ด ์‚ฌ์šฉ

  • ๊ทธ๋ฆผ