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.