Difference between pageEncoding and contentType in JSP

Source: Internet
Author: User



Differences between the pageEncoding and contentType attributes on the JSP page:

PageEncoding isJsp file itselfEncoding

ContentTypeCharset refers to the content encoding when the server sends data to the client.

JSP requires two "Encodings". pageEncoding is used in the first stage, UTF-8 to UTF-8 is used in the second stage, and the third stage is the webpage from Tomcat, with contentType.

The first stage isJsp is compiled into. java, which reads jsp according to pageEncoding settings.The result is translated by the specified encoding scheme into the unified UTF-8 JAVA source code (namely. java), if pageEncoding is set wrong, or not set, it is the Chinese garbled.

The second stage isCompilation from JAVA source code of JAVAC to java byteCodeNo matter what encoding scheme is used in JSP writing, after this stage, all the results are the UTF-8's encoding java source code.

JAVAC uses the UTF-8's encoding to read the java source code and compile it into the UTF-8's encoding binary code (that is,. class), which is the JVM's specification for the constant string expression in the binary code (java encoding.

The third stage is the JAVA binary code loaded and executed by Tomcat (or its application INER) in stage 2. The output result is displayed on the client, in this case, the parameter contentType hidden in phase 1 and Phase 2 is effective.

ContentType

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.