How to check for Double.NaN in JSP with JSTL tags?
Is something like this:
<c:if test="$variable eq Double.NaN">
what you're looking for?
It'd be nice if Java constants were "visible" in EL, JSTL however doesn't work with them.
Workaround could be to put Double.NaN into scope of JSTL (e.g. put it to applicatioScope by making it a servlet attribute) programatically.
There also is a Jakarta tag library doing this: http://jakarta.apache.org/taglibs/sandbox/doc/unstandard-doc/intro.html (see useConstant tag). However, I've never used that, and the library itself seem to be in sandbox for ages. But it can at least give an idea of how to do implement this :)
The "NaN" is just outputted as a String. So
<c:if test="${variable == 'NaN'}">
should do.
One thing to look out for when working with Double.NaN is that Double.NaN (I think it is even in the IEEE spec) is supposed to compare as not equal to everything including NaN.
Hence, the only way to properly check if a number is NaN (apart from creating a String out of it) is to see if the value != value. JSTL is not my cup of tea but I guess it is valid there as well.
Read more in Wikipedia