Monday, October 25, 2010

JSP and contentType attributes of pageEncoding

On the JSP page contentType pageEncoding and the difference between two properties:

pageEncoding jsp file itself is encoded

contentType the charset is when the server sends the content to the client code

JSP to go through two "codes", the first phase will use pageEncoding, the second phase will use utf-8 to utf-8, the third stage is from the Tomcat out of the pages, use the contentType.

The first stage is the jsp compiled. Java, it will be set according to pageEncoding read jsp, the result is translated by the specified encoding scheme into a single UTF-8 JAVA source (ie. Java), if pageEncoding set wrong or not set, out of that Chinese garbage.

In the second phase JAVAC the JAVA source to compile java byteCode, regardless of when the JSP write what encoding scheme used, the results of this stage and all the encoding is UTF-8 in the java source.

JAVAC with the encoding UTF-8 reading java source code, compiled into UTF-8 encoding of binary code (ie. Class), this is the JVM of the constant string in the binary code (java encoding) expression within the norms.

The third stage is the Tomcat (or the application container) loading and execution phases II to the JAVA binary code, the output, that is, the client can see, this time hidden in the phase I and phase II parameter contentType played an effect on

contentType setting.

pageEncoding and the contentType the default is ISO8859-1. and casually set one, the other would follow as a (TOMCAT4.1.27 so). but this is not absolute, depending on their JSPC approach. The pageEncoding does not mean contentType, better text CJKV Asia Department of JSP page development and display, (eg pageEncoding = GB2312 does not mean contentType = utf-8).

jsp files like. java,. java being read into the compiler when the default is set by the operating system corresponding to the locale encoding, such as mainland China is GBK, Taiwan is BIG5 or MS950. We are both in general and in ue in Notepad to write code, specially if there is no transcoding, then write out the contents of all the local encoding format. Therefore, the compiler approach virtual machine can just get the correct information.

Jsp file is not the case, however, it does not the default transcoding process, but specifies pageEncoding transcoding can be achieved right up.

For example:

Metropolitan print out garbled because the input "Hello" is gbk, but the server is properly captured, "Hello" is not known.

However, if the change

This server will be caught right "hello" the.

Recommended links:

Extreme Programming (eXtreme Programming) Summary

Concerned about the anti-monopoly law enforcement agency jurisdiction overlap

Good HTML Tools


evaluation PIMS And Calendars

2008 Zhongguancun Top Ten News: Premier Wen INSPECTED Zhongguancun selected


Simple Site Administration


LiveMotion Make the drop-down menu

Red Hat, JBoss founder and PROSPECTS may leave doubt

Free patterns subversive

Basic Framework For JSF

Thinking like a CONSULTANT as

your computer can run faster by CLEANING your

No comments:

Post a Comment