본문 바로가기
🎵JSP

[JSP] JSTL c:set c:out

by 김말자 2023. 2. 13.
728x90
728x90
BIG

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<c:set var="a" value="20" />
<!-- request.setAttribute("b",30) --> //setAttribue에 담아서 뭐.뭐 이렇게 안나오는거임
<c:set var="b" value="30" scope="request" /> //같은 이름일 경우만 scope 명시

<!-- session.setAttribute("c",40) -->
<c:set var="c" value="40" scope="session" /> //set은 특정범위만 지정해주는 역할
<!-- application.setAttribute("d",50) -->
<c:set var="d" value="50" scope="application" />
<h2>jstl,el을 이용한 출력</h2>
a=
<c:out value="${a }" />
<br> b=
<c:out value="${b }" />
<br> c=
<c:out value="${c }" />
<br> d=
<c:out value="${d }" />
<br>
<hr>
a=
${a }
<br> b=
${b }
<br> c=
${c }
<br> d=
${d }
</body>
</html>

 

728x90
반응형
BIG

댓글