Response.setcontenttype and Response.setcharacterencoding Difference Analysis _jsp programming in JSP

Source: Internet
Author: User

This article illustrates the difference between Response.setcontenttype and response.setcharacterencoding in JSP. Share to everyone for your reference, specific as follows:

Response.setcontenttype

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

That means that the server sits on this setting, and then he will play a role in the browser, deciding how to encode when you open the browser

If the method is invoked before the Response.getwriter () is invoked, the character encoding of the response is set only from the given content type. If the method is invoked after Response.getwriter () is invoked or after being committed, the character encoding of the response is not set, and in the case of using the HTTP protocol, the method sets the Content-type entity header

Response.setcharacterencoding sets the encoding of the response

If the server side uses Response.setcontenttype to set the encoding format,
Then you should use Response.setcharacterencoding to specify the encoding format, so that the previous settings will be blocked off

General Recommended Settings response.setcharacterencoding

Response.setcontenttype often encounter failures (settings but often do not work)

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

Related Article

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.