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.
With GET parameters works fine, but with POST parameters always the same with new servlets. Old servlets work fine post parameters.
I tested receiving parameters with php and they are correctly formated, so I discart the posibility of being the jsp encoding.
I think may be netbeans error, but I really dont know.
Here some code and images:
The servlet
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("> Ñ,ñ, tílde. Parámetros: " + request.getParameter("name"));
}
The JSP:
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<form method="post" action="/TestParameters">
<input type="text" name="name">
<button type="submit">Enviar</button>
</form>
</body>
</html>
Html input:
NetBeans console with POST parámeters:
Netbeans console with GET parámeters:
And receiving with php, works well:
echo $_POST['name'];
Php html echo: