Tag <c:remove> xóa biến khỏi scope chỉ định hoặc scope đầu tiên tìm thấy biến (nếu không chỉ định scope). Hành động này hỗ trợ dọn dẹp tài nguyên scope mà JSP chịu trách nhiệm.
Thuộc tính
| Attribute | Description | Required | Default |
|---|---|---|---|
| var | Tên biến cần xóa | Yes | None |
| scope | Scope của biến cần xóa | No | All scopes |
Ví dụ
<%@ taglib uri = "https://java.sun.com/jsp/jstl/core" prefix = "c" %>
<html>
<head> <title><c:remove> Tag Example</title> </head>
<body>
<c:set var = "salary" scope = "session" value = "${2000*2}" />
<p>Before Remove Value: <c:out value = "${salary}" /></p>
<c:remove var = "salary" />
<p>After Remove Value: <c:out value = "${salary}" /></p>
</body>
</html>
Kết quả:
Before Remove Value: 4000 After Remove Value: