title: Servlet response.sendRedirect encoding problems
body: <p>So I'm redirecting my user using GET in a naive way:</p>
  
  <pre><code>response.sendRedirect("/path/index.jsp?type="+ e.getType() 
     +"&amp;message="+ e.getMessage());
  </code></pre>
  
  <p>And this was working fine until I had to send messages, as actual text to be shown to users. The problem is if the message has non-ASCII characters in it. My .jsp files are encoded in UTF-8:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=UTF-8"
      pageEncoding="UTF-8"%&gt;
  </code></pre>
  
  <p>So all non-ASCII characters in 'message' gets garbled. I don't want to set my JVM default encoding to UTF-8, so how do I solve this? I tried to use</p>
  
  <pre><code>response.setCharacterEncoding("UTF-8");
  </code></pre>
  
  <p>on the Servlet before redirecting, but it doesn't work. when I try to execute:</p>
  
  <pre><code>out.print(request.getCharacterEncoding());
  </code></pre>
  
  <p>on my .jsp file it prints 'null'.</p>