Bug 29109

Summary: empty operator doesn't work with java.util.Set instances
Product: Taglibs Reporter: Willis Boyce <wboyce>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED INVALID    
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   

Description Willis Boyce 2004-05-20 02:09:01 UTC
${empty someSet} will return false if someSet is an instance of java.util.Set, 
even if it is, in fact, empty.  This is because EmptyOperator.java checks for 
an empty Map and an empty List but not an empty Collection.  All that needs to 
be done is to replace List with Collection, as a List is, of course, a 
Collection.
Comment 1 Justyna Horwat 2004-05-20 17:36:17 UTC
Submitted by Michael Santos:

----
Regarding this bug:

That's the expected behaviour in JSTL 1.0, according to the spec.

I don't have a bugzilla user and I am not a committer, so, I am unable to
help this user more.

Reference:
http://weblogs.java.net/pub/wlg/730

Regards,
Michael Nascimento Santos
----

In your bug report, you didn't specify which version of JSTL you are using.

If you are using JSTL 1.0 then this is the expected behavior. If you look at section A.3.8 of the JSTL 1.0 
specification you will find the empty operator defined as follows:

empty A is evaluated as follows: 

■  If A is null, return true, 
■ Otherwise, if A is the empty string, then return true. 
■ Otherwise, if  A isan empty array, then return true. 
■ Otherwise, if A is an empty Map, return true 
■ Otherwise, if A is an empty List, return true, 
■ Otherwise return false.

With JSTL 1.1 the EL was moved to the JSP 2.0 specification domain. With JSTL 1.1 it is now up to the 
domain of the JSP container to support the JSP 2.0 EL implementation.

In JSP 2.0 the empty operator behavior has changed slightly. In JSP 2.0 section JSP.2.3.7, the empty 
operator behaves as follows:

• If A is null, return true, 
• Otherwise, if A is the empty string, then return true. 
• Otherwise, if A is an empty array, then return true. 
• Otherwise, if A is an empty Map, return true, 
• Otherwise, if A is an empty Collection, return true, 
• Otherwise return false.

Moving to JSTL 1.1 and a JSP 2.0 container will address your problem.