${fooBean.fooMap.containsValue("baz")}
The above will work in JSP 2.2 or higher. If you are using a pre-JSP 2.2 container (e.g. Java EE 5), then the EL function is probably the best solution.
Java static method:
package contains;
import java.util.Map;
public class Maps {
public static boolean containsValue(Map<?, ?> map, Object value) {
return map.containsValue(value);
}
}
File WEB-INF/tlds/maps.tld:
<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.1"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd">
<tlib-version>1.0</tlib-version>
<short-name>maps</short-name>
<uri>/WEB-INF/tlds/maps</uri>
<function>
<description>Returns true if the value is contained</description>
<name>containsValue</name>
<function-class>contains.Maps</function-class>
<function-signature>
boolean containsValue(java.util.Map, java.lang.Object)
</function-signature>
</function>
</taglib>
Using:
<%@taglib prefix="maps" uri="/WEB-INF/tlds/maps" %>
...
${maps:containsValue(fooBean.fooMap, "baz")}
source
share