MapleStory Finger Point

๐ŸŸค JAVA/๐ŸŸค JSP

[JSP] JSP ๊ตฌ์„ฑ ์š”์†Œ (๊ฐ„๋‹จ ์ •๋ฆฌ)

HYEJU01 2024. 8. 23. 23:01

1. ๋””๋ ‰ํ‹ฐ๋ธŒ Directive

JSP ํŽ˜์ด์ง€ ์„ค์ • ์ •๋ณด๋ฅผ ์ง€์ •ํ•  ๋•Œ ์‚ฌ์šฉ

<%@ page contentType = "text/html; charset=utf-8" %>

 

page ํŽ˜์ด์ง€ ์ •๋ณด ์ง€์ • 
taglib ์‚ฌ์šฉ ํ•  ํƒœ๊ทธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ์ง€์ •
include ํŠน์ • ์˜์—ญ์— ๋‹ค๋ฅธ ๋ฌธ์„œ ํฌํ•จ์‹œํ‚จ๋‹ค.

 

 

2.  ์Šคํฌ๋ฆฝํŠธ 

 

๋ฌธ์„œ์˜ ๋‚ด์šฉ์„ ๋™์  ์ƒ์„ฑ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ 

๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์— ์ €์žฅ or ๋ฐ์ดํ„ฐ ์ถœ๋ ฅ ๊ฐ€๋Šฅํ•˜๋‹ค.

 

ํ‘œํ˜„์‹ (Expression) ๊ฐ’ ์ถœ๋ ฅ

์Šคํฌ๋ฆฝํŠธ๋ฆฟ (Scriptlet) ์ž๋ฐ” ์ฝ”๋“œ ์‹คํ–‰

์„ ์–ธ๋ถ€ (Declaration) ์ž๋ฐ” ๋ฉ”์„œ๋“œ ์ƒ์„ฑ

 

 

3. ๊ธฐ๋ณธ ๊ฐ์ฒด

request ์š”์ฒญ ํŒŒ๋ผ๋ฏธํ„ฐ ์ฝ์–ด์˜ค๊ธฐ
response ์‘๋‹ต ๊ฒฐ๊ณผ ์ „์†ก 
session ์„ธ์…˜ ์ฒ˜๋ฆฌ
application ์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ •๋ณด ์ฝ์–ด์˜ค๊ธฐ
page  
๋“ฑ๋“ฑ...  

 

 

 

4. ํ‘œํ˜„ ์–ธ์–ด

 

์Šคํฌ๋ฆฝํŠธ์š”์†Œ๋Š” ... 

์žฅ์  : ์ž๋ฐ” ๋ฌธ๋ฒ•์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•˜๋‹ค.

๋‹จ์  : JSP ์ฝ”๋“œ๊ฐ€ ๋ณต์žกํ•ด์ง << ์ด ์ ์„ ํ‘œํ˜„ ์–ธ์–ด๋กœ ํ•ด๊ฒฐ ๊ฐ€๋Šฅ !

 

<%
int num = Interger.parseInt(requset.getParameter("a"));
%>

a * b <%= a * b %>

 

 

์ด๋ ‡๊ฒŒ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ์ง€๋กฑ

 

a * b = {$param.a * param.b}

 

 

 

 

5. ํ‘œ์ค€ ์•ก์…˜ ํƒœ๊ทธ , ํƒœ๊ทธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ 

 

์•ก์…˜ํƒœ๊ทธ : JSP ํŽ˜์ด์ง€์—์„œ ํŠน๋ณ„ํ•œ ๊ธฐ๋Šฅ๋“ค์„ ์ œ๊ณตํ•ด์คŒ ex) <jsp:include>

<jsp:์•ก์…˜ํƒœ๊ทธ์ด๋ฆ„>

 

์ปค์Šคํ…€ ํƒœ๊ทธ : JSP ๋ฅผ ํ™•์žฅ ์‹œ์ผœ์ฃผ๋Š” ๊ธฐ๋Šฅ  (๊ฐœ๋ฐœ์ž๊ฐ€ ์ง์ ‘ ๊ฐœ๋ฐœ)

 

ํƒœ๊ทธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ : ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๊ฒƒ๋“ค์„ ํ‘œ์ค€ํ™” ํ•ด๋‘” ํƒœ๊ทธ ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ex) JSTL