I have the following in my .jsp file:

```
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
...
<fmt:message key="mykey.${country}" />

```

For some countries this key exists and the message is shown as expected, for others it does not exist. If it does not exist I get the following output:

```
???mykey.DE??? 

```

which I don't want. I would expect to have no output if the key does not exist.

`mykey.${country}` resolves to either

* mykey.DE
* mykey.SE
* mykey.US
* mykey.GB
* ...

I don't know which one it will be but I need to check if it exists as a variable.

**Is there a way to check this or to hide the unwanted output?**

---

What I tried so far:

I tried to surround it with

```
<c:if test="$(not empty mykey.${country})">
  <fmt:message key="mykey.${country}" />
</c:if>

```

but it doesn't work: the message is never displayed, even if the key exists.

I also tried to put it into a local variable first:

```
<c:set var="localVar" value="mykey.${country}" />
<c:out value="${localVar}" /> <!-- this prints 'mykey.DE' correctly -->
<c:if test="!empty ${localVar}">
    <div style="padding-top:10px;">
    <fmt:message key="mykey.${country}" />
    </div>
</c:if>

```

But the check does not work as intended.