code: public static int length(Object obj) throws JspTagException {
          if (obj == null) {
              return 0;
          }
  
          if (obj instanceof String) {
              return ((String) obj).length();
          }
          if (obj instanceof Collection) {
              return ((Collection) obj).size();
          }
          if (obj instanceof Map) {
              return ((Map) obj).size();
          }
          if (obj instanceof Iterator) {
              int count = 0;
              Iterator iter = (Iterator) obj;
              while (iter.hasNext()) {
                  count++;
                  iter.next();
              }
              return count;
          }
          if (obj instanceof Enumeration) {
              Enumeration enum_ = (Enumeration) obj;
              int count = 0;
              while (enum_.hasMoreElements()) {
                  count++;
                  enum_.nextElement();
              }
              return count;
          }
          if (obj.getClass().isArray()) {
              return Array.getLength(obj);
          }
          throw new JspTagException(Resources.getMessage("PARAM_BAD_VALUE"));
      }
docs: Returns the number of items in a collection or the number of characters in a string.
  The collection can be of any type supported for the <code>items</code> attribute of
  the <code>&lt;c:forEach&gt;</code> action.
  
  @param obj the collection or string whose length should be computed
  @return the length of the collection or string; 0 if obj is null
  @throws JspTagException if the type is not valid