First, you must read the html file from the browser. The html file you write must be encoded in a certain character set. Therefore, when the browser reads html files into the memory, it must first decode them. I mainly decode them, and I will omit other processes ). Then the browser must have a character set encoded by itself. Then the browser reads data from the memory for encoding and then displays the page.
In this way, we assume that the page has a form with a text input box. In the text input box, enter Chinese characters such as "hello "). Click Submit. The browser receives the request assuming that the submission method is post ). The browser data encoding is transmitted to the servlet engine. Servlet Engine to decode the data, the default is the ISO-8859-1, you can use the request. setCharacterEncoding method to set. The decoded data is sent to the request. The servlet component reads "hello" from the request. Assume that the first function to be implemented is to return "hello" to the page and display it on the page. Then the servlet will establish a connection with response, encode "hello", and then pass "hello" to response. The servlet Engine reads data from response and transmits the data to the browser. I don't think we need to perform encoding or decoding. Because you have stored the "hello" encoded data in responese ),
The browser receives the data, decodes the data, reads it into the memory, then reads the memory content, encodes it, and displays it on the page.
There may be some points that you are not considering.