How to store a character using JSTL <c:set>

java, jstl

Solution

<c:set var="letter" value="${param.colorLetter.toLowerCase().charAt(0).toString()}" />

<c:choose>
    <c:when test="${letter eq 'v'}">
        <lable>Color Name: </lable>Violet<br/>
    </c:when>
</c:choose>

You have to put the whole test between `${}` and to add `toString()` after your `charAt(0)` to cast from `Character` to `String`.

Problem

I wanted to store a character value in a variable using the JSTL My code to do this is: ``` <c:set var="letter" value='${param.colorLetter.toLowerCase().charAt(0)}' ></c:set> ``` Next i need to try and check if the character was 'v': ``` <c:choose> <c:when test="${letter}=='v'"> <lable>Color Name: </lable>Violet<br/> </c:when> </c:choose> ``` Currently I feel that it is not storing it as a Character Variable and so the test is failing. (No errors/exceptions)

Original source