JSP - YiGD96/JSP_Project GitHub Wiki

JSP

1. JSP์™€ Servlet์˜ ์ฐจ์ด

  • JAVA
    HTML์ฝ”๋“œ์•ˆ์— JAVA์˜ ๋ฌธ๋ฒ•์ด ํ˜ผํ•ฉ๋œ ํ˜•์‹์ด๋‹ค.
    presentation(View)์— ์ข‹๋‹ค.
    ๊ธฐ๋ณธ์ ์œผ๋กœ๋Š” HTML ๋ฌธ๋ฒ•, <% %>๋ถ€๋ถ„์€ JAVA๋ฌธ๋ฒ•

  • Servlet
    JAVA์ฝ”๋“œ์•ˆ์— HTML์˜ ๋ฌธ๋ฒ•์ด ํ˜ผํ•ฉ๋œ ํ˜•์‹์ด๋‹ค.
    data processing(Controller)์— ์ข‹๋‹ค.
    DB์™€์˜ ํ†ต์‹ , Business Logic ํ˜ธ์ถœ, ๋ฐ์ดํ„ฐ๋ฅผ ์ฝ๊ณ  ํ™•์ธํ•˜๋Š” ์ž‘์—… ๋“ฑ์— ์œ ์šฉํ•˜๋‹ค.

2. Request ๋ฉ”์‹œ์ง€

  1. GET ๋ฐฉ์‹ : ๋ณธ๋ฌธ์€ ํ•„์š”์—†๊ณ , 256byte ํ•œ๊ณ„
    ์ฃผ์†Œ ๋’ค์— ํŒŒ๋ผ๋ฏธํ„ฐ๋„ ๊ฐ™์ด ๋‚ ๋ผ๊ฐ

    ์˜ˆ์ œ : <www.example.com?id=mommoo&pass=1234>

  2. POST๋ฐฉ์‹ : ๋ณธ๋ฌธ์ด ๊ฐ™์ด ์ „์†ก๋˜๋ฉฐ, ํ•œ๊ณ„๊ฐ€ ์—†๋‹ค. ๋ณด์•ˆ์ƒ ์œ ์šฉํ•˜๋‹ค

    ์˜ˆ์ œ : <www.example.com>

3. ์ง€์‹œ์–ด <%@ %>

์ง€์‹œ์–ด๋ž€ JSP์—์„œ ํ•ด๋‹น ํŽ˜์ด์ง€๋ฅผ ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ•  ๊ฒƒ์ธ๊ฐ€์— ๋Œ€ํ•œ ์„ค์ • ์ •๋ณด๋“ค์„ ์ง€์ •

1. page ์ง€์‹œ์–ด

  • <%@ page language="java" %> ์Šคํฌ๋ฆฝํŠธ์—์„œ ์‚ฌ์šฉํ•  ์–ธ์–ด ์„ค์ •
  • <%@ page import="java.util.*, java.io.*" %> JSPํŽ˜์ด์ง€ ๋‚ด์—์„œ ์‚ฌ์šฉํ•  ํŒจํ‚ค์ง€ ๋˜๋Š” ํด๋ž˜์Šค๋ฅผ import ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ
  • <%@ page contentType="text/html" %> JSPํŽ˜์ด์ง€๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ๋ฌธ์„œํ˜•์‹ ( ๊ทธ ์™ธ image/gif, video/avi์‹์˜ type/subtype์œผ๋กœ ์ง€์ •๊ฐ€๋Šฅํ•˜๋‹ค )
  • <%@ page pageEncoding="euc-kr" %> ๋ฌธ์ž์…‹ ์ธ์ฝ”๋”ฉ ๋ฐฉ์‹์„ ์ง€์ •ํ•ด์ค€๋‹ค.
         <%@ page contentType="text/html;charset=euc-kr" %> ๊ณผ ๊ฐ™์ด ์“ธ ์ˆ˜ ์žˆ๋‹ค.
  • <%@ page info="๋‹ค์Œ๊ณผ ๊ฐ™์ด ์ดํŽ˜์ด์ง€์— ๋Œ€ํ•ด์„œ ์„ค๋ช…" %> ํ•ด๋‹น ์ „์ฒด ํŽ˜์ด์ง€์— ๋Œ€ํ•ด์„œ ์„ค๋ช…ํ•ด์ฃผ๊ณ  ์‹ถ์€ ์ฃผ์„

2. include ์ง€์‹œ์–ด

  • <%@ include file="header.jsp" %> ๋‹ค๋ฅธ ํŒŒ์ผ์˜ jsp์˜ ์†Œ์ŠคํŒŒ์ผ์„ ๊ฐ€์ ธ์™€์„œ ์“ธ ์ˆ˜ ์žˆ๋‹ค.

3. taglib ์ง€์‹œ์–ด

?????????????????????

โš ๏ธ **GitHub.com Fallback** โš ๏ธ