Java - Servlet post parameters bad encoding
<p>I was working normally on my netbeans project. I sent post parameters from html forms to servlets and then capture them with request.getParameter... and all worked fine. But some hours ago, I don't know what happened with netbeans because all new servlets that I create, the requested post parameters are not encoded well. I mean that if I send "tílde" or "ñ" it will be received as "tÃ­lde" or "Ã±". The old servlets still work fine, receiving well the post parameters.</p>

<p>With GET parameters works fine, but with POST parameters always the same with new servlets. Old servlets work fine post parameters.</p>

<p>I tested receiving parameters with php and they are correctly formated, so I discart the posibility of being the jsp encoding.</p>

<p>I think may be netbeans error, but I really dont know.</p>

<p>Here some code and images:</p>

<p>The servlet</p>

<pre><code>public class TestParameters extends HttpServlet {

protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();

    System.out.println("&gt; Ñ,ñ, tílde. Parámetros: " + request.getParameter("name"));
}
</code></pre>

<p>The JSP:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form method="post" action="/TestParameters"&gt;
            &lt;input type="text" name="name"&gt;
            &lt;button type="submit"&gt;Enviar&lt;/button&gt;
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;</code></pre>
</div>
</div>
</p>

<p>Html input:</p>

<p><a href="https://i.stack.imgur.com/L5mA6.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L5mA6.jpg" alt="Text for example"></a></p>

<p>NetBeans console with POST parámeters:</p>

<p><a href="https://i.stack.imgur.com/SQum4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SQum4.jpg" alt="enter image description here"></a></p>

<p>Netbeans console with GET parámeters:</p>

<p><a href="https://i.stack.imgur.com/VX2ZY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VX2ZY.jpg" alt="enter image description here"></a></p>

<p>And receiving with php, works well:</p>

<pre><code>echo $_POST['name'];
</code></pre>

<p>Php html echo:</p>

<p><a href="https://i.stack.imgur.com/L4woS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L4woS.jpg" alt="enter image description here"></a></p>