java

JSP - ๊ฒŒ์‹œํŒ๋งŒ๋“ค๊ธฐ(10) ๋กœ๊ทธ์ธ -v2(Cookie,ELํ‘œํ˜„์‹, JSTL ์ ์šฉ)

dev_summer 2020. 11. 9. 15:46

 

1. ELํ‘œํ˜„์‹

https://www.javatpoint.com/EL-expression-in-jsp

 

JSP Expression Language | EL - javatpoint

JSP Expression Language or EL with examples of session tracking, implicit objects, el, jstl, mvc, custom tags, file upload, file download, interview questions etc.

www.javatpoint.com

 

2. JSP Scope๋ž€?

pageScope > requestScope > sessionScope > applicationScope

ํ‚ค ๊ฐ’์ด ์ค‘๋ณต๋˜๋ฉด ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด scope์˜ value๋ฅผ returnํ•œ๋‹ค.

 

	<h1>test2 page : ${pageScope.phone}</h1>
	<h1>test2 request : ${requestScope.phone}</h1>
	<h1>test2 session : ${sessionScope.phone}</h1>
	<h1>test2 param : ${param.phone}</h1>

 

 

 

3. ELํ‘œํ˜„์‹์œผ๋กœ Cookie ์‚ฌ์šฉํ•˜๊ธฐ

<h1>Cookie : ${cookie.username.value}</h1>

 

 

usernameCookie๋Š” ๋‚ด๊ฐ€ ์ฟ ํ‚ค์— ์ €์žฅํ•œ key๊ฐ’์ด๋‹ค.

 

4. EL ํ‘œํ˜„์‹์œผ๋กœ request๊ฐ’ ๊ฐ€์ ธ์˜ค๊ธฐ

- ๋ณ€์ˆ˜๋Š” orivate์ด์ง€๋งŒ ์ฐพ์„๋•Œ getterํ•จ์ˆ˜๋ฅผ ํ˜ธ์ถœํ•œ๋‹ค.

 

${๋ณ€์ˆ˜๋ช…}

 

5. JSTL

(1) ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ํ•„์š”ํ•˜๋‹ค.

https://mvnrepository.com/artifact/javax.servlet/jstl

 

Maven Repository: javax.servlet » jstl

Professional Java Data: RDBMS, JDBC, SQLJ, OODBMS, JNDI, LDAP, Servlets, JSP, WAP, XML, EJBs, CMP2.0, JDO, Transactions, Performance, Scalability, Object and Data Modeling (2001)by Carl Calvert Bettis, Michael Bogovich, Sean Rhody, Mark Wilcox, Kelly Lin P

mvnrepository.com

 

 

(2) tag๊ฐ€ ํ•„์š”

HTMLl๊ณผ ๊ตฌ๋ถ„ํ•˜๊ธฐ ์œ„ํ•ด tag lib(์ง€์‹œ์ž)๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

๊ฐ€์žฅ ์œ„์— ์œ„์น˜ํ•˜๊ณ ์žˆ๋‹ค. include์˜ ๊ธฐ๋ณธ์…‹ํŒ…์— ๋„ฃ์œผ๋ฉด ๋จ

 

   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

 

 

(3) JSTL Core ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ

https://www.javatpoint.com/jstl

 

JSTL Tutorial and Examples - javatpoint

JSTL Tutorial with examples on JSTL core tags, function tags, formatting tags, sql tags and miscellaneous tags. It includes c:out, c:import, c:set, c:if, c:when, c:choose, c:redirect, c:catch etc.

www.javatpoint.com

6. ํšŒ์›๊ฐ€์ž…, ๋กœ๊ทธ์ธ, ๋ฏธ์™„(profile,logout ๋‚จ์Œ)

 

 

7. ๊ฒŒ์‹œ๊ธ€ ์“ฐ๊ธฐ, ๊ฒŒ์‹œ๊ธ€ ์ˆ˜์ •, ๊ฒŒ์‹œ๊ธ€ ๋ชฉ๋ก๋ณด๊ธฐ, ๊ฒŒ์‹œ๊ธ€ ์ƒ์„ธ๋ณด๊ธฐ, ๊ฒŒ์‹œ๊ธ€ ์‚ญ์ œํ•˜๊ธฐ ๋‚จ์Œ

8. ์ถ”๊ฐ€ ํ•  ์˜ˆ์ •

(1). ์ธ๋จธ๋…ธํŠธ(ํ…์ŠคํŠธ์—๋””ํ„ฐ)

(2). ๊ณต๊ณต๋ฐ์ดํ„ฐ ์ฃผ์†Œ api-userํ…Œ์ด๋ธ” ์ฃผ์†Œ ์นผ๋Ÿผ ์ถ”๊ฐ€

(3). youtube ํŒŒ์‹ฑ-JSoup

(4). ๋Œ“๊ธ€

(5). ๊ฒ€์ƒ‰ํ•˜๊ธฐ

 

 

 

 

 

* null์„ ๋Œ€ํ•˜๋Š” ๊ฐ์ฒด

optional ๊ฐ์ฒด๋ฅผ ์ด์šฉํ•˜๋ฉด null์ผ์ˆ˜๋„ ์žˆ๋Š” ๊ฐ’์˜ ๊ธฐ๋ณธ๊ฐ’์„ ์…‹ํŒ… ํ•ด ์ค„์ˆ˜ ์žˆ๋‹ค

 

String remamberMe = Optional.ofNullable(req.getParameter("rememberMe")).orElse("off");