code: public static int getIntSelector(SlingHttpServletRequest request, int defaultValue) {
          String[] selectors = request.getRequestPathInfo().getSelectors();
          for (String selector : selectors) {
              try {
                  return Integer.parseInt(selector);
              } catch (NumberFormatException nfex) {
                  // ok, try next
              }
          }
          return defaultValue;
      }
docs: Retrieves a number in the selectors and returns it if present otherwise the default value.
  
  @param request      the request object with the selector info
  @param defaultValue the default number value