Esempio n. 1
0
  /**
   * Set the Locale that is appropriate for this response, including setting the appropriate
   * character encoding.
   *
   * @param locale The new locale
   */
  @Override
  public void setLocale(Locale locale) {

    if (isCommitted()) {
      return;
    }

    // Ignore any call from an included servlet
    if (included) {
      return;
    }

    coyoteResponse.setLocale(locale);

    // Ignore any call made after the getWriter has been invoked.
    // The default should be used
    if (usingWriter) {
      return;
    }

    if (isCharacterEncodingSet) {
      return;
    }

    String charset = getContext().getCharset(locale);
    if (charset != null) {
      coyoteResponse.setCharacterEncoding(charset);
    }
  }
Esempio n. 2
0
  /**
   * Set the content type for this Response.
   *
   * @param type The new content type
   */
  @Override
  public void setContentType(String type) {

    if (isCommitted()) {
      return;
    }

    // Ignore any call from an included servlet
    if (included) {
      return;
    }

    if (type == null) {
      coyoteResponse.setContentType(null);
      return;
    }

    String[] m = MEDIA_TYPE_CACHE.parse(type);
    if (m == null) {
      // Invalid - Assume no charset and just pass through whatever
      // the user provided.
      coyoteResponse.setContentTypeNoCharset(type);
      return;
    }

    coyoteResponse.setContentTypeNoCharset(m[0]);

    if (m[1] != null) {
      // Ignore charset if getWriter() has already been called
      if (!usingWriter) {
        coyoteResponse.setCharacterEncoding(m[1]);
        isCharacterEncodingSet = true;
      }
    }
  }
Esempio n. 3
0
  /*
   * Overrides the name of the character encoding used in the body
   * of the request. This method must be called prior to reading
   * request parameters or reading input using getReader().
   *
   * @param charset String containing the name of the character encoding.
   */
  @Override
  public void setCharacterEncoding(String charset) {

    if (isCommitted()) {
      return;
    }

    // Ignore any call from an included servlet
    if (included) {
      return;
    }

    // Ignore any call made after the getWriter has been invoked
    // The default should be used
    if (usingWriter) {
      return;
    }

    coyoteResponse.setCharacterEncoding(charset);
    isCharacterEncodingSet = true;
  }