JSTL Core Tag c:remove Example
- Details
- Written by Nam Ha Minh
- Last Updated on 31 August 2019   |   Print Email
This post helps you understand and use the <c:remove> tag in the JSTL core tags library with code example.
The <c:remove> tag removes a scoped variable from its scope. We can specify the scope from where the variable to be removed. If no scope is provided, the variable will be removed from all the scopes.
JSTL <c:remove> Syntax:
<c:remove var="<string>" scope="<string>"/>
Attributes:
Name | Required | Type | Description |
var | True | java.lang.String | Name of the scoped variable to remove from scope. |
scope | False | java.lang.String | Scope where the variable can be found. (Optional) |
JSTL <c:remove> Example:
The below example a variable into session scope and prints its value before and after removing it from the session scope.
<c:set var="userName" scope="session" value="Code Java"/> <p>Before removing value from session: <c:out value="${userName}"/></p> <c:remove var="userName"/> <p>After removing value from session: <c:out value="${userName}"/></p>
Output:
Recommended Usage of JSTL <c:remove> tag:
This tag may be useful in cases where JSP can clean up any scoped variable it has set.
Other JSTL Core Tags:
if | catch | choose | forEach | forTokens | import | out | param | redirect | set | url
Comments