JSTL c:set Core Tag

The JSTL <c:set> Core Tag is used to set a value to a variable or object in a specific scope like session. It works like setProperty action but the difference is that it can take a expression as an input, evaluate it and assign result to a variable or object.

Syntax: <c:set var=”varName” value=”value/expression” />

c:set tag attributes:

Attribute Description Required
value Information to save. No
target Name of the variable whose property should be modified. No
property Property to modify. No
var Name of the variable to store information. No
scope Scope of variable to store information. No

Example:

test.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
 
<html>
	<head>
		<title>c:set JSTL core tag example</title>
	</head>
	<body>
		<c:set var="website" value="www.javawithease.com"/>
		<c:out value="${website}"/>
	</body>
</html>

web.xml

<web-app>
 
  <welcome-file-list>
          <welcome-file>test.jsp</welcome-file>
  </welcome-file-list>	
 
</web-app>

Output:

jsp example 32
 
Download this example.
 
Next Topic: JSTL c:remove Core Tag with example.
Previous Topic: JSTL c:out Core Tag with example.

Related Topics:

JSTL c:out Core Tag with example.
JSTL c:set Core Tag with example.
JSTL c:remove Core Tag with example.
JSTL c:catch Core Tag with example.
JSTL c:if Core Tag with example.
JSTL c:choose , c:when and c:otherwise Core Tags with example.
JSTL c:import Core Tag with example.
JSTL c:forEach Core Tag with example.
JSTL c:forTokens Core Tag with example.
JSTL c:url Core Tag with example.
JSTL c:param Core Tag with example.
JSTL c:redirect Core Tag with example.