How can I validate if a String
is null or empty using the c
tags of JSTL
?
I have a variable of name var1
and I can display it, but I want to add a comparator to validate it.
<c:out value="${var1}" />
I want to validate when it is null or empty (my values are strings).
You can use
alternatively.
This code is correct but if you entered a lot of space (' ') instead of null or empty string return false.
To correct this use regular expresion (this code below check if the variable is null or empty or blank the same as org.apache.commons.lang.StringUtils.isNotBlank) :