FreeKB - JSTL - How to create a variable using c:set and c:out
JSTL - How to create a variable using c:set and c:out

Home > Search > How-to


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

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" 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.

${name}

 

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 c5ad3 in the box below so that we can be sure you are a human.




Comments