code: private static Locale findFormattingMatch(PageContext pageContext,
              Locale[] avail) {
          Locale match = null;
          for (Enumeration enum_ = Util
                  .getRequestLocales((HttpServletRequest) pageContext
                          .getRequest()); enum_.hasMoreElements();) {
              Locale locale = (Locale) enum_.nextElement();
              match = findFormattingMatch(locale, avail);
              if (match != null) {
                  break;
              }
          }
  
          return match;
      }
docs: Determines the client's preferred locales from the request, and compares
  each of the locales (in order of preference) against the available
  locales in order to determine the best matching locale.
  
  @param pageContext Page containing the formatting action @param avail
  Available formatting locales
  
  @return Best matching locale, or <tt>null</tt> if no match was found