Difference Analysis Between response. setContentType and response. setCharacterEncoding in JSP, response. contenttype

Source: Internet
Author: User

Difference Analysis Between response. setContentType and response. setCharacterEncoding in JSP, response. contenttype

This article describes the differences between response. setContentType and response. setCharacterEncoding in JSP. We will share this with you for your reference. The details are as follows:

Response. setContentType

Sets the content type of the response sent to the client, which can include the description of character encoding.

That is to say, if this setting is configured on the server side, it will act on the browser side and decide the encoding method when you open the browser.

If this method is called before response. getWriter () is called, the character encoding of the response is set only from the given content type. If the method is in response. after getWriter () is called or called after submission, no response character encoding is set. When http is used, this method sets the Content-type object header.

Response. setCharacterEncoding

If the server uses response. setContentType to set the encoding format,
The encoding format specified by response. setCharacterEncoding should be used to block the previous settings.

We recommend that you set response. setCharacterEncoding.

Response. setContentType is often invalidated (set but often does not work)

I hope this article will help you with JSP program design.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.