code: protected String getRealIdScope()
      {
          ServletRequest request = pageContext.getRequest();
          
          // default to the set idScope.
          String idScope = _idScope;
  
          // if there isn't a set idScope and generate scope is on, generate the scope id.
          if (_idScope == null && _genScope) {
              int id = getNextId(request);
              idScope = "n" + Integer.toString(id);
              _idScope = idScope;
          }
          
          // if there's still no idScope and we're in a ScopedRequest, use the scope-key from the request.
          if (_idScope == null) {
              ScopedRequest scopedRequest = ScopedServletUtils.unwrapRequest(request);
              if (scopedRequest != null) {
                  _idScope = scopedRequest.getScopeKey().toString();
                  idScope = _idScope;
              }
          }
          
          return idScope;
      }
docs: This method will return the real scope id for the script container.
  @return String