<c:remove> 태그를 이용한 실습
JSP 페이지에서 변수를 선언했으면 <c:remove> 태그를 이용해 변수를 제거할 수도 있습니다.
<c:remove var="변수이름" [scope="scope 속성 중 하나"] />
여기서 var은 제거할 변수 이름을, scope는 변수 범위(scope)를 작성합니다(page, request, session, application 중 하나).
1. member3.jsp를 다음과 같이 작성합니다. <c:remove> 태그를 이용해 <c:set>으로 선언한 변수를 삭제합니다.
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
request.setCharacterEncoding("UTF-8");
%>
<c:set var="id" value="hong" scope="page" />
<c:set var="pwd" value="1234" scope="page" />
<c:set var="name" value="${'홍길동'}" scope="page" />
<c:set var="age" value="${22}" scope="page" />
<c:set var="height" value="${177}" scope="page" />
<c:remove var="age" />
<c:remove var="height" />
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>회원 정보 출력창</title>
</head>
<body>
<table align="center" border="1" >
<tr align="center" bgcolor="lightgreen" >
<td width="7%" ><b>아이디</b></td>
<td width="7%" ><b>비밀번호</b></td>
<td width="7%" ><b>이름</b></td>
<td width="7%"><b>나이</b></td>
<td width="7%" ><b>키</b></td>
</tr>
<tr align="center">
<td>${id}</td>
<td>${pwd}</td>
<td>${name}</td>
<td>${age}</td>
<td>${height}</td>
</tr>
</table>
</body>
</html>
2. http://localhost:8090/pro14/test03/member3.jsp로 요청합니다. <c:remove> 태그를 이용해 변수 age의 height를 삭제했기 때문에 아무 값도 출력되지 않습니다.

'프로그래밍 언어 > 자바 웹' 카테고리의 다른 글
| <c:choose> 태그를 이용한 실습 (0) | 2026.02.19 |
|---|---|
| <c:if> 태그를 이용한 실습 (0) | 2026.02.15 |
| <c:set> 태그를 이용한 실습(2) (0) | 2026.02.09 |
| <c:set> 태그를 이용한 실습(1) (0) | 2026.02.06 |
| Core 태그 라이브러리 사용하기 & <c:set> 태그를 이용한 실습 (0) | 2026.02.03 |