[Web] 9. step04_JSP(3) - jsp action tag

์ง„์ฃผยท2022๋…„ 2์›” 9์ผ
0

Web

๋ชฉ๋ก ๋ณด๊ธฐ
12/17
post-custom-banner

๐Ÿ‘€ action tag ?

JSPํŽ˜์ด์ง€ ๋‚ด์—์„œ ์–ด๋–ค ๋™์ž‘์„ ํ•˜๋„๋ก ์ง€์‹œํ•˜๋Š” ๊ฒƒ

JSPํŽ˜์ด์ง€์—์„œ ์ž๋ฐ” ์ฝ”๋“œ ๋“ฑ์˜ ์Šคํฌ๋ฆฝํŠธ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  HTMLํƒœ๊ทธ ํ˜•ํƒœ๋กœ ๋‹ค๋ฅธ ํŽ˜์ด์ง€๋‚˜ ์ž๋ฐ” ๊ฐ์ฒด์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•œ ๊ธฐ๋Šฅ์ด๋‹ค.

์‚ฌ์šฉ ๋ฐฉ๋ฒ• : <jsp: [action tag] ~~/>


JSPAction Tags Description์‚ฌ์šฉ๋ฐฉ๋ฒ•
jsp:forward์š”์ฒญ์„ ๋‹ค๋ฅธ ์ž์›์œผ๋กœ ์ „๋‹ฌํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ<jsp:forward page="์ด๋™ํ•  ํŽ˜์ด์ง€ ์ด๋ฆ„"/>
jsp:include๋‹ค๋ฅธ ๋ฆฌ์†Œ์Šค๋ฅผ ํฌํ•จ์‹œํ‚จ๋‹ค<jsp:include page="์‚ฝ์ž…ํ•  ํŽ˜์ด์ง€" />
<jsp:forward> : forward(dispatcher) ๋ฐฉ์‹์œผ๋กœ ์›น ํŽ˜์ด์ง€๋ฅผ ์ด๋™ํ•˜๋Š” tag
		
forward tag๋กœ ์ด๋™๋˜๋Š” ์ตœ์ข… jsp์—์„œ์˜ ์ถœ๋ ฅ ๋กœ์ง์€ ํ™”๋ฉด์— ์‹คํ–‰๋˜์ง€๋งŒ
์ด ์ฝ”๋“œ๊ฐ€ ๊ตฌํ˜„๋œ jsp๊ฐ€ ์‹คํ–‰๋˜๊ธฐ๋Š” ํ•˜์ง€๋งŒ ๋ธŒ๋ผ์šฐ์ €์— ์ถœ๋ ฅ๋˜์ง€ ์•Š๋Š”๋‹ค.
        
๊ฒฐ๋ก ) ๋ณด์ด๋Š” ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” ๋‚ด์šฉ๋“ค์„ forward๋กœ ์ด๋™๋œ jsp์—์„œ ์ž‘์—…ํ•ด์•ผํ•œ๋‹ค
		
        
<jsp:include> : forward(dispatcher) ๋ฐฉ์‹์œผ๋กœ ์›น ํŽ˜์ด์ง€๋ฅผ ์ด๋™ํ•˜๋Š” tag
page ์†์„ฑ์— ์„ค์ •ํ•œ jsp ๋˜๋Š” servlet ๋‚ด์šฉ์„ ํ˜„ page์— ํฌํ•จ์‹œํ‚จ๋‹ค.

 ๊ฒฐ๋ก ) ๋‘ ํŒŒ์ผ ๋ชจ๋‘ ๊ฐ™์€ ํ™”๋ฉด์— ์ถœ๋ ฅ๋œ๋‹ค.

jsp2Scripting.jsp ์ƒ์„ฑ


"charset=UTF-8"๋กœ ๋ณ€๊ฒฝ

jsp2Scripting.jsp ์ฝ”๋“œ


jsp1Scripting.jsp ์ฝ”๋“œ ์ถ”๊ฐ€

	<!-- forward -->
	<jsp:forward page ="jsp2Scripting.jsp"/> 
	
	<!-- include -->
	<%-- <jsp:include page="jsp2Scripting.jsp"/> --%>

โ‘  forward ๊ฒฐ๊ณผ์ฐฝ

jsp1Scripting ์—์„œ Run as โ†’ Run on Server๋ฅผ ํ•œ๋‹ค๊ณ  ํ•˜๋”๋ผ๋„,
<jsp:forward page ="jsp2Scripting"/> ๋กœ ์ธํ•ด์„œ
๋ฐ”๋กœ jsp2Scripting ํ™”๋ฉด์œผ๋กœ ๋„˜์–ด๊ฐ„๋‹ค.


โ‘ก include ๊ฒฐ๊ณผ์ฐฝ

<jsp:include page="jsp2Scripting.jsp"/> ๋กœ ์ธํ•ด์„œ
jsp2Scripting์— ์žˆ๋Š” ๋‚ด์šฉ์ด jsp1Scripting์— ์ถœ๋ ฅ๋œ๋‹ค.

include action tag์˜ ์žฅ์  : ์ฝ”๋“œ์˜ ์žฌ์‚ฌ์šฉ์„ฑ

๋ชจ๋“  ํŽ˜์ด์ง€์— ๋จธ๋ฆฌ๊ธ€ ๋ฐ ๋ฐ”๋‹ฅ ๊ธ€ ํŽ˜์ด์ง€๋ฅผ ํฌํ•จํ•˜๋Š” ๋“ฑ ์—ฌ๋Ÿฌ ํŽ˜์ด์ง€๋ฅผ ์žฌ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค.


[๋ฒˆ์™ธ] jsp๊ฐ€ servlet์œผ๋กœ ๋ณ€ํ™˜๋˜์–ด ์ž๋™์ ์œผ๋กœ ์ €์žฅ๋˜๋Š” ํŒŒ์ผ ์œ„์น˜ ์ฐพ๊ธฐ

C:\20220103_lab\03.Web1.metadata.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\step04_JSP\org\apache\jsp
์— ์กด์žฌํ•˜๋Š” jsp1_Scripting_jsp.java ํŒŒ์ผ Visual Studio Code๋กœ ์‹คํ–‰ํ•ด๋ณด๊ธฐ


Q. jsp ์ฝ”๋“œ ์ˆ˜์ • ํ›„์— ๊ฐฑ์‹ ๋œ ๋‚ด์šฉ์œผ๋กœ serviceํ•˜๋ ค ํ•˜๋Š”๋ฐ ๊ฐฑ์‹ ์ด ๋˜์ง€ ์•Š๋Š” ์ƒํ™ฉ์ด ๋ฐœ์ƒ๋  ๊ฒฝ์šฐ?

A. C:\20220103_lab\03.Web1\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\step04_JSP\org\apache\jsp
	

โ†’ jsp๊ฐ€ servlet์œผ๋กœ ๋ณ€ํ™˜๋˜์–ด ์ €์žฅ๋˜์–ด์žˆ๋Š” ์œ„์น˜(โ†‘)์—์„œ servlet ์‚ญ์ œ ํ›„์— jsp ์žฌ์‹คํ–‰ ํ•ด๋ณธ๋‹ค.

profile
์ง„์ฃผ์˜ ์ฝ”๋”ฉ์ผ๊ธฐ
post-custom-banner

0๊ฐœ์˜ ๋Œ“๊ธ€