Step 1. Set the charset of the web page to an encoding this is supported through your goal languages. I generally tend to apply UTF-eight as it covers maximum languages. The following meta announcement in an HTML/JSP web page will set the content material kind:
Step 2. In the web page JavaScript ensures to encode any parameters despatched to the server. JavaScript gives the getaway() feature which returns Unicode get away strings wherein localized textual content will seem in hexadecimal format. For extra information on JavaScript encoding see evaluating get away(), encodeURI(), and encode URI Component().
Step 3. On the server-aspect aspect, set the man or woman encoding the use of the HttpServletRequest.setCharacterEncoding() approach. Before you get admission to the localized parameter the use of the HttpServletRequest.getParameter() name. In the case of UTF this will be request .set Character Encoding (“UTF-eight”);.
A server – aspect returning AJAX responses desires to set the encoding of the reaction to the identical encoding used at the web page.
reaction.setContentType("textual content/xml;charset=;UTF-eight");
reaction.getWriter().write(" invalid ");