I'm going to use jQuery Ajax to post requests:
var xhr = $.ajax({
url: "/UsersCounter",
type: "POST",
cache: false,
data: {"emailAddr": "example@domain.com"},
dataType: "text",
contentType: "application/json"
});
and server side I have a simple servlet to handle http requests:
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
String x=req.getParameter("emailAddr");
...
}
In browsers parameter of emailAddr
is visible in POST requests but value of x
is null
in the servlet. Is there anything wrong with this code?