The <c:set> tag is JSTL-friendly version of the setProperty action. The tag is helpful because it evaluates an expression and uses the results to set a value of a JavaBean or a java.util.Map object.
JSTL Set Tag Example,
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head> <title><c:set> Tag Example</title> </head> <body> <c:set var="salary" scope="session" value="${50000*2}"/> <c:out value="${salary}"/> </body> </html>
As you can see above, in the set tag, new variable “salary” is created and value is set to 100000. In the next line, it prints the valued of salary variable using out tag.
This would produce following result:
100000
Attribute:
The <c:set> tag has following attributes:
Attribute | Description | Required | Default |
---|---|---|---|
value | Information to save | No | body |
target | Name of the variable whose property should be modified | No | None |
property | Property to modify | No | None |
var | Name of the variable to store information | No | None |
scope | Scope of variable to store information | No | Page |
Strategy Design Patterns We can easily create a strategy design pattern using lambda. To implement…
Decorator Pattern A decorator pattern allows a user to add new functionality to an existing…
Delegating pattern In software engineering, the delegation pattern is an object-oriented design pattern that allows…
Technology has emerged a lot in the last decade, and now we have artificial intelligence;…
Managing a database is becoming increasingly complex now due to the vast amount of data…
Overview In this article, we will explore Spring Scheduler how we could use it by…