code: protected static int getIntInitParameter(ServletContext servletContext, String parameterName, int defaultValue) {
      final String parameterString = servletContext.getInitParameter(parameterName);
      if(parameterString != null && parameterString.trim().length() > 0) {
        try {
          return Integer.parseInt(parameterString);
        }
        catch (NumberFormatException e) {
          // Do nothing, return default value
        }
      }
      return defaultValue;
    }
docs: Parse init parameter for integer value, returning default if not found or invalid