본문 바로가기
study/Jsp

[Jsp] 17. EL 표현언어 (JSTL core 태그 [set, remove, out])

by 금이패런츠 2022. 4. 13.
728x90
반응형
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- /src/main/webapp/jstl/jstlcoreex1.jsp --%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JSTL core 태그</title>
</head>
<body>
<h3>속성 관련 태그 : set, remove, out 태그</h3>
<% //session.setAttribute("test", "Hello JSTL"); %>
<%-- c : prefix, 접두어 --%>
<c:set var="test" value="${'Hello JSTL'}" scope="session" /> <%--set으로 속성 등록 --%>
test 속성 : ${sessionScope.test} <br>
test 속성 : <c:out value="${test}" /> <br> <%--out으로 속성 출력. EL만 쓰는것보단 보안이 좋음--%>
test 속성 : ${test}<br>

<% //session.removeAttribute("test"); %>
<c:remove var="test" /> <%--remove로 속성 삭제 --%>

<br>
test 속성 : ${sessionScope.test} <br>
test 속성 : <c:out value="${test}" /> <br> 
test 속성 : ${test}<br>
</body>
</html>

chap16 JSTL.pdf
0.28MB

728x90
반응형