code: public void setContentType(String contentType) 
      {
          if (isCommitted() || contentType==null)
              return;
          
          int semi=contentType.indexOf(';');
          if (semi>0)
          {
              int charset0=contentType.indexOf("charset=",semi);
              if (charset0>0)
              {
                  if (_outputState==WRITER_OUT)
                  {
                      // need to strip charset= from params
                      int charset1=contentType.indexOf(' ',charset0);
                      
                      if ((charset0==semi+1 && charset1<0) ||
                          (charset0==semi+2 && charset1<0 && contentType.charAt(semi+1)==' ' ))
                          _httpResponse.setContentType(contentType.substring(0,semi));
                      else if (charset1<0)
                          _httpResponse.setContentType(contentType.substring(0, charset0).trim());
                      else
                          _httpResponse.setContentType(contentType.substring(0, charset0)+contentType.substring(charset1));
                  }
                  else
                  {
                      _charEncodingSetInContentType=true;
                      _httpResponse.setContentType(contentType);
                  }
              }
              else
                  _httpResponse.setContentType(contentType);
          }
          else
              _httpResponse.setContentType(contentType);
          
          if (_locale!=null)
              setLocale(_locale);
      }
docs: /* ------------------------------------------------------------