Research on JSP page encoding (original)

Source: Internet
Author: User

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

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.