code: protected CmsObject initCmsObjectFromSession(HttpServletRequest req) throws CmsException {
  
          String url = req.getRequestURL().toString();
          String p = "[ " + url + " ] ";
          if (LOG.isDebugEnabled()) {
              LOG.debug(p + "Trying to init cms object from session for request \"" + req.toString() + "\".");
          }
          // try to get an OpenCms user session info object for this request
          CmsSessionInfo sessionInfo = m_sessionManager.getSessionInfo(req);
  
          if (sessionInfo == null) {
              if (LOG.isDebugEnabled()) {
                  LOG.debug(p + "No session info found.");
              }
              return null;
          }
  
          // initialize the requested site root
          CmsSite site = getSiteManager().matchRequest(req);
  
          // a user name is found in the session manager, reuse this user information
          CmsUUID project = sessionInfo.getProject();
  
          // initialize site root from request
          String siteroot = sessionInfo.getSiteRoot();
          if (siteroot == null) {
              // not sure if this can actually happen?
              LOG.debug(p + "site root from session info was null, determining site root from current request's host");
              siteroot = site.getSiteRoot();
          }
          // initialize user from request
          CmsUser user = m_securityManager.readUser(null, sessionInfo.getUserId());
  
          if (LOG.isDebugEnabled()) {
              LOG.debug(p + "Initializing cms object with user \"" + user.getName() + "\".");
              LOG.debug(p + "siteRoot = " + siteroot);
          }
          return initCmsObject(req, user, siteroot, project, sessionInfo.getOrganizationalUnitFqn());
      }
docs: Initializes a new cms object from the session data of the request.<p>
  
  If no session data is found, <code>null</code> is returned.<p>
  
  @param req the request
  
  @return the new initialized cms object
  
  @throws CmsException if something goes wrong