title: Can not send special characters (UTF-8) from JSP to Servlet: question marks displayed
body: <p>I have a problem sending special characters like cyrillic or umlauts from a jsp to a servlet.
  I would greatly appreciate your help here.</p>
  
  <p>Here is what I have done:</p>
  
  <ol>
  <li><p>Defined the utf-8 charset in the jsp:</p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=utf-8" 
      pageEncoding="utf-8"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
  "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
   &lt;head&gt;
    &lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&gt;
   ...
  
  &lt;div class="authentication"&gt;
    &lt;form name="registerForm" action="register" method="get" accept-charset="UTF-8"&gt;
      &lt;input type="input" name="newUser" size="17"/&gt;
      &lt;input type="submit" value="senden" /&gt;
    &lt;/form&gt;
  &lt;/div&gt;
   ...
  </code></pre></li>
  <li><p>Set Tomcat URIEncoding for Connector, in the server.xml</p>
  
  <pre><code>&lt;Connector URIEncoding="UTF-8" ...
  </code></pre></li>
  <li><p>Inside the servlet - set the CharacterEncoding to UTF and read request</p>
  
  <pre><code>public void doGet (HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
  
  request.setCharacterEncoding("UTF-8");
  String username = request.getParameter("newUser");
  System.out.println("encoding: "+request.getCharacterEncoding());
  
  System.out.println("received: "+username);
  </code></pre></li>
  <li><p>Here is what gets displayed when using for example: <strong>Однако</strong></p>
  
  <pre><code>encoding: UTF-8
  received: ??????
  </code></pre></li>
  </ol>
  
  <p>Am I missing something ? I suppose the servlet can not decode the String properly, but I have no idea why is this happening. I've followed all the advises on this topic but had no luck.</p>
  
  <p>thanks in advance. </p>