code: public static String getTitleInfo(CmsFlexController controller, HttpServletRequest req) {
  
          String result = null;
          CmsObject cms = controller.getCmsObject();
  
          try {
  
              CmsJspStandardContextBean contextBean = CmsJspStandardContextBean.getInstance(req);
              if (contextBean.isDetailRequest()) {
                  // this is a request to a detail page
                  CmsResource res = contextBean.getDetailContent();
                  CmsXmlContent content = CmsXmlContentFactory.unmarshal(cms, res, req);
                  result = content.getHandler().getTitleMapping(cms, content, cms.getRequestContext().getLocale());
                  if (result == null) {
                      // title not found, maybe no mapping OR not available in the current locale
                      // read the title of the detail resource as fall back (may contain mapping from another locale)
                      result = cms.readPropertyObject(res, CmsPropertyDefinition.PROPERTY_TITLE, false).getValue();
                  }
              }
              if (result == null) {
                  // read the title of the requested resource as fall back
                  result = cms.readPropertyObject(
                      cms.getRequestContext().getUri(),
                      CmsPropertyDefinition.PROPERTY_TITLE,
                      true).getValue();
              }
          } catch (CmsException e) {
              // NOOP, result will be null
          }
          if (CmsStringUtil.isEmptyOrWhitespaceOnly(result)) {
              result = "";
          }
  
          return result;
      }
docs: Returns the title of a page delivered from OpenCms, usually used for the <code>&lt;title&gt;</code> tag of
  a HTML page.<p>
  
  If no title information has been found, the empty String "" is returned.<p>
  
  @param controller the current OpenCms request controller
  @param req the current request
  
  @return the title of a page delivered from OpenCms