Jsp (preferred for SUN Enterprise applications)Research on page Encoding
Motivition
A netizen once asked me this question:
<% @ Page contentType = "text/html; charset = UTF-8" %>
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
</Head>
<Body>
China
</Body>
</Html>
Why does the "China" page become garbled during operation?
Analysis Key Step
For the analysis of the above problem, we needJsp (preferred for SUN Enterprise applications)The lifecycle of page requests generally goes through the following stages:
1. Application ServerJsp (preferred for SUN Enterprise applications)GenerateJavaFile
2. Application Server callJava.exeSetJavaCompile the file into oneServletCorrespondingClassFile
3. Users' browser requestsJsp (preferred for SUN Enterprise applications)CorrespondingServlet,WebThe container starts a thread for execution.ServletTo return the data to the client browser.
4. User'sIEDisplays the returned data to the user.
Key Step Analysis
To better understand the coding problem, we will analyze the problem step by step from the above four links and obtain the final solution based on the analysis results.
1. On the application serverJsp (preferred for SUN Enterprise applications)Page generationJavaFile phase.
The Application ServerJsp (preferred for SUN Enterprise applications)The page code is read and written to a newJAVAAn encoding problem is involved in reading and writing files. How does the app server solve this encoding problem? My researchTomcat (a very useful JSP running platform)Application Server Source Code, foundTomcat (a very useful JSP running platform)There isPageEncoding