FreeKB - JSTL variable using c:set and c:out
Java Programming - JSTL variable using c:set and c:out

Creating variables in JSTL is incredibly easy. First, add the following line to the top of your JSP page.

<%@ taglib uri="" prefix="c" %>


Use c:set to create a variable. In this example, a variable called name is created with a value of Jeremy. This is a key:value pair.

<c:set var="name" value="Jeremy"/>


This markup should print the value of the variable called name, which will print Jeremy in this example.



In this example, when running the app, "Jeremy" is displayed.

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 6d08f in the box below so that we can be sure you are a human.