docs: public void setContentType(String type) {
          final boolean isTraceOn = com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled();
          // 311717
          if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
              logger.entering(CLASS_NAME,"setContentType", " type --> " + type+ " ["+this+"]");
          }
          //PM50313
          if (type == null){
              if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                  logger.exiting(CLASS_NAME,"setContentType","not set - type is NULL");
              }  
              return;
          }
          //PM50313
  
          // d151464 - check the include flag
          WebAppDispatcherContext dispatchContext = (WebAppDispatcherContext) getRequest().getWebAppDispatcherContext();
          if (dispatchContext.isInclude() == true) {
              if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                  logger.exiting(CLASS_NAME,"setContentType", nls.getString("Illegal.from.included.servlet", "Illegal from included servlet"));  //311717
              }
              return;
          }
  
  
          if (isCommitted()){
              if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                  logger.exiting(CLASS_NAME,"setContentType","not set - response isCommitted");  //311717
              }
              return;
          }
  
          int equalsIndex = type.indexOf('=');
          boolean containsCharset = false;
          int beginCharsetStrIndex = equalsIndex - 7;
          int startCharsetValIndex = equalsIndex + 1;
          boolean isPreV7 = false;
          if (contentTypeCompatibility!=null && (contentTypeCompatibility.equalsIgnoreCase("V4")||
                          contentTypeCompatibility.equalsIgnoreCase("V5")||contentTypeCompatibility.equalsIgnoreCase("V6"))){
              isPreV7 = true;
          }
  
          boolean addEncoding = false;
  
          if (beginCharsetStrIndex > -1){
              containsCharset = type.regionMatches(true, beginCharsetStrIndex, "charset", 0, 7);
          }
          if (containsCharset){
              if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                  logger.logp(Level.FINE, CLASS_NAME,"setContentType", " isPreV7 --> " + isPreV7);
              }
              if (!_gotWriter) {  // 249506, part 2
                  // Example:
                  // setContentType("text/html;charset=UTF-8")
                  // getWriter();
                  // result = text/html;charset=UTF-8
                  // we can change the character encoding because we haven't gotten the writer or committed
                  // Begin 287829, Fix setContentType when qoutes are a part of the charset
  
                  int endIndex = type.length() - 1;
                  if (startCharsetValIndex<=endIndex){
                      isCharEncodingExplicit = true;
                      boolean startsWithQoute = type.charAt(startCharsetValIndex) == '"' || type.charAt(startCharsetValIndex) == '\'';
                      boolean endsWithQoute = type.charAt(endIndex) == '"' || type.charAt(endIndex) == '\'';
                      if (startsWithQoute && endsWithQoute){
                          _encoding = type.substring(startCharsetValIndex + 1, endIndex);
                          addEncoding = true;
                          // remove the qoutes from the encoding and add later
                      }
                      else {
                          _encoding = type.substring(startCharsetValIndex);
                          // type is perfectly formed and can be set as is.
                      }
  
                  }
                  // End 287829, Fix setContentType when qoutes are a part of the charset
              }
              else {
                  if (isPreV7){
                      // Before v7, strip the charset
                      // Example:
                      // setContentType("text/html");
                      // getWriter();
                      // setContentType("text/xml;charset=UTF-8");
                      // result = text/xml
                      if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                          logger.logp(Level.FINE, CLASS_NAME,"setContentType", " isPreV7, strip charset ");
                      }
                      type = type.substring(0, beginCharsetStrIndex).trim();
                      // if (type.endsWith(";")) { //wasteful??? It has to end with ;
                      type = type.substring(0, type.length() - 1);
                      // }
                  }
              }
          }
          if (!isPreV7){
              if (_gotWriter){
                  //we've gotten the writer, but not committed, so we can change the mime type,
                  //but not the charset. Still we have to add the default encoding or the previous
                  // charset
                  // setContentType("text/html;charset=ISO-8859-7");
                  // getWriter();
                  // setContentType("text/xml;charset=UTF-8");
                  // result = text/xml;charset=ISO-8859-7
                  if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                      logger.logp(Level.FINE, CLASS_NAME,"setContentType", " add encoding because we retrieved a writer");
                  }
                  addEncoding = true;
              }
              else {
                  //we haven't gotten the writer, and the current contentType argument has no
                  //charset included. Therefore check to see if the old content type has a charset
                  // and append it *** if the new type is some form of text ***
                  // setContentType("text/html;charset=UTF-8");
                  // setContentType("text/xml");
                  // result = text/xml;charset=UTF-8
                  if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                      logger.logp(Level.FINE, CLASS_NAME,"setContentType", " did not get writer, check to see if charset already exists");
                  }
                  if (isCharEncodingExplicit&&type.startsWith(WebContainerConstants.TEXT)){ //506208.1
                      if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
                          logger.logp(Level.FINE, CLASS_NAME,"setContentType", " add encoding because the content type already had a charset");
                      }
                      addEncoding = true;
                  }
              }
          }
  
          if (addEncoding)
          {
              if (containsCharset){
                  type = type.substring(0, startCharsetValIndex) + _encoding;
              }
              else
              {
                  type = type + ";" + WebContainerConstants.CHARSET_EQUALS + _encoding;
              }
          }
          /* 252465: We do not want to do the autoResponseEncoding check here
           * because this sets the charset for binary data also.
           * Only use in the case of getWriter.
           */
          _contentType = type;
          if (_response != null)
              _response.setContentType(type);
  
          if (isTraceOn&&logger.isLoggable (Level.FINE)) {  //306998.15
              logger.exiting(CLASS_NAME,"setContentType","type="+_contentType);  //311717
          }
  
      }