title: Why UTF-8 contents not displayed in a servlet deployed in jetty?
body: <p>I am trying to test a Servlet with special character which is deployed in jetty 9.
  I am posting a String with a single quote character to the Servlet. Though I have mentioned to use UTF-8 character encoding in the Servlet , the Servlet cannot print the single quote character. I don't know what's wrong in the following code :</p>
  
  <pre><code>import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStreamReader;
  
  
  public class SpecialCharacterServlet extends HttpServlet {
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
          request.setCharacterEncoding("UTF-8");
          BufferedReader in = new BufferedReader(
                  new InputStreamReader(request.getInputStream()));
          String inputLine;
  
          while ((inputLine = in.readLine()) != null) {
              System.out.println(inputLine);
          }
  
          in.close();
  
      }
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  
      }
  
  
  }
  </code></pre>
  
  <p>The main method</p>
  
  <pre><code>public static void main(String s[]) {
          try {
  
              HttpURLConnection conn = (HttpURLConnection) new URL("http://localhost:8080/test/SpecialCharacterServlet").openConnection();
              conn.setDoInput(true);
              conn.setDoOutput(true);
              conn.setUseCaches(false);
              conn.setRequestMethod("POST");
              conn.setRequestProperty("Connection", "Keep-Alive");
              conn.setRequestProperty("Content-Type", "multipart/form-data;boundary=*****");
  
              String str = "Hello ‘World’";
              DataOutputStream dos = new DataOutputStream(conn.getOutputStream());
              dos.writeBytes(str);
              dos.flush();
              dos.close();
  
              InputStream is = conn.getInputStream();
              byte[] content = new byte[is.available()];
              is.read(content);
  
          }catch(Exception e) {
              System.out.println(e);
          }
      }
  </code></pre>
  
  <p>The output does not show the single quoted  character , the output is <code>Hello World</code> , it's some block in there .</p>