title: encoding problem in servlet
body: <p>I have a servlet which receive some parameter from the client ,then do some job.
  And the parameter from the client is Chinese,so I often got some invalid characters in the servet.
  For exmaple:
  If I enter</p>
  
  <pre><code>http://localhost:8080/Servlet?q=中文&amp;type=test
  </code></pre>
  
  <p>Then in the servlet,the parameter of 'type' is correct(test),however the parameter of 'q' is not correctly encoding,they become invalid characters that can not parsed.</p>
  
  <p>However if I enter the adderss bar again,the url will changed to :</p>
  
  <pre><code>http://localhost:8080/Servlet?q=%D6%D0%CE%C4&amp;type=test
  </code></pre>
  
  <p>Now my servlet will get the right parameter of 'q'.</p>
  
  <h2>What is the problem?</h2>
  
  <p><strong><code>UPDATE</code></strong></p>
  
  <p>BTW,it words well when I send the form with post. 
  WHen I send them in the ajax,for example: </p>
  
  <pre><code>url="http://..q='中文',
  xmlhttp.open("POST",url,true); 
  </code></pre>
  
  <p>Then the server side also get the invalid characters. </p>
  
  <p>It seems that just when the Chinese character are encoded like %xx,the server side can get the right result. </p>
  
  <p>That's to say <code>http://.../q=中文</code> does not work,
  <code>http://.../q=%D6%D0%CE%C4</code> work. </p>
  
  <p>But why "<code>http://www.google.com.hk/search?hl=zh-CN&amp;newwindow=1&amp;safe=strict&amp;q=%E4%B8%AD%E6%96%87&amp;btnG=Google+%E6%90%9C%E7%B4%A2&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai=</code>" work？
  <img src="https://i.stack.imgur.com/PKkIw.jpg" alt="alt text"></p>