code: protected CmsObject getCmsObject(HttpServletRequest req) throws CmsException {
  
          CmsObject cms = OpenCmsCore.getInstance().initCmsObjectFromSession(req);
          // use the guest user as fall back
          if (cms == null) {
              cms = OpenCmsCore.getInstance().initCmsObject(OpenCms.getDefaultUsers().getUserGuest());
              String siteRoot = OpenCmsCore.getInstance().getSiteManager().matchRequest(req).getSiteRoot();
              cms.getRequestContext().setSiteRoot(siteRoot);
          }
          String baseUri = getBaseUri(req, cms);
          if (baseUri != null) {
              cms.getRequestContext().setUri(baseUri);
          }
          return cms;
      }
docs: Returns the CMS object.<p>
  
  @param req the request
  
  @return the CMS object
  
  @throws CmsException if something goes wrong