JSTL When Test Error

A simple error using JSTL using the <c:when test></when> comparison was faced when TechieDan was doing his coding and has been boggling his mind for awhile.

JSTL Error Action

What do you know when a simple task of comparing values in the client scripting page turned out to be something like this. Using JSTL to do comparison has never been that easy for comparing values. Though there is one small mistake.

<c:when test="${registrationForm.customerGroup eq 'D'} ">

From the above, the code should work without errors. But lo and behold, there was a super slight mistake and it took about 30 minutes to figure it out. All you need to do is

<c:when test="${registrationForm.customerGroup eq 'D'}">

Any difference in the code? There definitely is. There’s a slight space after the “}” symbol. This will instead be interpreted by the compiler that you’re checking for “D ” instead of “D” without the space.

Sometimes we look at the codes and wonder what’s wrong. At times it’s just a simple mistake and we go crazy over it. It’s always good to know you’ve solved a simple mistake like this.

One Response

  1. danielctw January 3, 2011

Leave a Reply