We are still using J2EE 1.3 and use "unstandard-taglibs". The Tag <size> doesn't work with arrays - it returns -1. Error is in the class "org.apache.taglibs.unstandard.SizeTag": // Error if(target instanceof Collection) { result = ( (Object[])target ).length; } // Bugfix if(target.isArray) { result = ( (Object[])target ).length; } And the casting (Object[]) doesn't works with primitive arrays (int[], boolean[], etc).
Created attachment 22282 [details] Sample jsp with <size>-Tag
svn ci -m "Fixing bugzilla entry 45433. SizeTag doesn't accept arrays" Sending src/main/java/org/apache/taglibs/unstandard/SizeTag.java Transmitting file data . Committed revision 778359. Index: src/main/java/org/apache/taglibs/unstandard/SizeTag.java =================================================================== --- src/main/java/org/apache/taglibs/unstandard/SizeTag.java (revision 775710) +++ src/main/java/org/apache/taglibs/unstandard/SizeTag.java (working copy) @@ -75,8 +75,15 @@ if(target instanceof String) { result = ( (String)target ).length(); } else - if(target instanceof Collection) { - result = ( (Object[])target ).length; + if(target.getClass().isArray()) { + try { + Field lengthField = target.getClass().getField("length"); + result = lengthField.getInt(target); + } catch(NoSuchFieldException nsfe) { + throw new JspException("Array found without a length field", nsfe); + } catch(IllegalAccessException iae) { + throw new JspException("Array found with a non-accessible length field", iae); + } } } if(var == null && result != -1) {