This is ayaka from Kids Programming Class ITWORKS. I will sew between childcare and describe it. This time I will forget the confirmation part about the garbled Japanese parameters of the HTML form data during my own development, so I will summarize it ☺️
This is because with the default settings, when Japanese parameters are sent as HTML form data, they are URL-encoded and sent to the email address indicated by action, the Jakarta Servlet of the Web server, etc. ** In other words, if you do not take measures, only Japanese parameters need to be decoded: sweat_smile: **
--For POST transmission
Specify the character encoding declared in the HTML file in setCharacterEncoding of HttpServlet.HttpServletRequest. In case of POST transmission Since the parameters to be transmitted are included in the HTTP request body, it can be handled by setting HttpServletRequest.
--For GET transmission
Decode with the character encoding declared in the HTML file.
:SampleHttpServlet.java
form_data_in_japanese = request.getParameter("form-name");
URLEncoder.encode(form_data_in_japanese , "Character encoding");
In the case of GET transmission, nothing is described in the HTTP request body: flushed: It is added to the URL and sent. Therefore, if the acquired parameters include Japanese, decoding is required.