In JSP, I want to compare two variables
If I do:
8}\">
It treats both values as Strings, and compares them lexicographically.
Try
<c:set var="pagerTotDisp" value="${9}"/>
<c:set var="TotalPages" value="${10}"/>
<c:if test="${TotalPages < pagerTotDisp}">
<span>This condition is not true. This text should not be displayed</span>
</c:if>
You're hardcoding the value in the value attribute of <c:set>. The <c:set> treats the hardcoded values as String. EL is therefore also evaluating them as String. Lexicographically, 9 is greater than 10, because 9 is at a further numerical position than 1.
There are two ways to solve this:
Set the value via an EL expression. It will be interpreted as Long instead of String.
<c:set var="pagerTotDisp" value="${9}" />
<c:set var="TotalPages" value="${10}" />
Or, use <fmt:parseNumber>, which would be the only solution if you have those as String variables from elsewhere which you have no control over.
<fmt:parseNumber var="pagerTotDisp" value="9" />
<fmt:parseNumber var="TotalPages" value="10" />