FreeKB - JSTL - if statements using c:if test
JSTL - if statements using c:if test

Home > Search


This assumes you are already familiar with creating variables using c:set and printing variables using c:out. Let's take an example of a variabled called name that contains a value of Jeremy.

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

 

The following if statement will print "Congratulations. Your name is Jeremy." if name equals Jeremy.

<c:if test="${name == 'Jeremy'}">
Congratulations. Your name is Jeremy.
</c:if>

 

Running this application should print "Congratulations. Your name is Jeremy."



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




Comments