728x90
반응형
SMALL
안녕하세요.
https://blog.naver.com/sysysy0302 여니입니다 :)
yeonee 블로그 : 네이버 블로그
예쁘고 맛있게 먹고 건강하게,강인하지만 온화하게 행하라. ※맛스타운스타일상 인스타 www.instagram.com/s2._.y25n ※맛집감성일상 유튜브https://youtube.com/channel/@S2_yeonee 티스토리https://yeoneeluv.tistory.co
blog.naver.com
<Servlet영역>
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setAttribute("big", 10); //대소비교
request.setAttribute("small", 3);
request.setAttribute("sOne", "안녕"); //대소비교
request.setAttribute("sTwo", new String("안녕"));
request.setAttribute("pOne", new Person("민경민",30,"남자")); //동등비교
request.setAttribute("pTwo", null);
ArrayList<String> list1 = new ArrayList<>(); //동등비교
request.setAttribute("lOne", list1);
ArrayList<String> list2 = new ArrayList<>();
list2.add("ㅎ");
request.setAttribute("lTwo", list2);
int count = 0;
for(String str : list2) {
count++;
}
request.getRequestDispatcher("views/1_EL/01_el.jsp").forward(request, response);
response.getWriter().append("Served at: ").append(request.getContextPath());
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
<01_el.jsp영역>
<h3>4. 객체가 null 인지 또는 리스트가 비어있는지 체크하는 연산</h3>
<p>
* EL연산 <br>
pTwo가 null입니까? ${ pTwo == null } 또는 ${ empty pTwo } <br>
pOne이 null입니까? ${ pOne == null } 또는 ${ empty pOne } <br>
lOne이 비어있습니까? ${ empty lOne} <br>
lTwo이 비어있습니까? ${ empty lTwo} <br>
</p>
<h3>5. 논리연산자</h3>
<p>
* EL연산 <br>
AND 연산 : ${ true && true } 또는 ${ true and true } <br>
OR 연산 : ${ true || false } 또는 ${ true or false } <br> <!-- 둘중하나라도 true면 true값 나올테니 false는 나올수없어서 노란줄 뜸 -->
</p>
<h3>연습문제</h3>
<p>
* EL연산에서 배운 "키워드"만 가지고 써볼것 <br>
1. big이 small보다 크고 lOne이 텅 비어있습니까? ${big gt small and empty lOne} <br>
2. big과 small의 곱은 4의 배수입니까? ${big * small mod 4 eq 0 } <br>
3. lTwo가 텅 비어있지 않거나 또는 sOne에 담긴 값이 "안녕하세요"와 일치합니까? ${ !empty lTwo or sOne eq "안녕하세요" }
</p>
논리연산자에서 and는 값이 둘 중 하나라도 false라면 결과값이 false이다.
논리연산자에서 or은 값이 둘 중 하나라도 true라면 결과값이 true이다.
<화면 출력 모습>
728x90
반응형
LIST
'⋆ 。゜☁︎ 。⋆ 。゜☾゜。⋆⋆ 。゜☁︎ 。⋆ 。゜☾゜。⋆ > JSP' 카테고리의 다른 글
[JSP] EL이란? (EL연산자 기호, EL연산자 우선순위, EL내장객체) (0) | 2023.07.31 |
---|---|
[JSP] JSP Action Tag (커스텀액션태그 - JSTL Functions) (0) | 2023.07.31 |
JSP - EL을 활용한 연산 (산술, 대소비교, 동등비교) (0) | 2023.07.30 |
JSP - 데이터들을 담을 수 있는 'JSP 내장객체 종류와 범위순서' (0) | 2023.07.30 |
JSP - 스클립틀릿과 표현식으로 / EL을 이용해서 'Scope에 저장된 값들 출력하기' (0) | 2023.07.30 |