Set & Remove in JSP Core Tag Library

What is "set", "remove" tag in JSP Core Tag Library?

Explanation

The set and remove tags are used to set and remove values for JSP EL variables or its property with the following scopes like page, request, session or application scope.

Syntax:


<c:remove var="var" [scope="page|request
|session|application"] />

Example :


<%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
<c:set var="i" value="${1}"/>
<c:set var="s" value="${2}"/>
<c:set var="j" value="${s+i}"/>
<p>Example of Core tag with "set"</p>
<c:out value="Sum = ${j}"/><br/>
Result :

Example of Core tag with "set"
Sum = 3

In the above example first the values for the variable "i", "s" are defined and the value of "j" is is set using an expression "{s+i}" all using the "<c:set" tag.

The "remove" tag can be used to remove an Expression Language Variable like below.

Example:


<c:remove var="i" scope="session"/>

Ask Questions

Ask Question