Here is my code (seen on Google App Engine)
public void doGet(HttpServletRequest request, HttpServletResponse response) {
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html; charset=UTF-8");
response.setHeader("testHeader1", "hi"); // Works fine
response.setHeader("testHeader2", "שלום"); // Header not visible on Chrome client
response.sendRedirect("/myUrl#שלום"); // Redirect does not work on browser (302 sent but Location header is absent)
Thanks!
The
RFC 2047specifies about non-ASCII characters in headers, but most of the servers and browsers does not support yet.So, if you want to send non-ASCII characters, you should be encoding the text to ASCII and send.
You can use
java.net.URLEncoderto encode while redirecting andjava.net.URLDecoderto decode at the other end.