Не могу разобраться почему пост-запрос не попадает в сервлет по урлу. Может что-то с ajax'ом намудрил?
function validate(event) {
if(document.getElementById("inputPassword").value !== document.getElementById("inputPasswordConfirm").value) {
alert("Passwords are different!!!")
event.preventDefault();
} else {
var data = {
login: document.getElementById("field1").value,
name: document.getElementById("field2").value,
surname: document.getElementById("field3").value,
email: document.getElementById("field4").value,
icq: document.getElementById("field5").value,
gender: document.getElementById("name").value,
password: document.getElementById("inputPassword")
};alert(data);
$.ajax({
type: 'POST',
url: '/newuserprocessing',
data: data,
success: function (data) {
alert(data);
},
error: function (data) {
alert(data);
}
});
}
}
@WebServlet("/newuserprocessing")
public class RegistrationServlet extends HttpServlet{
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println(req.getParameter("data"));
resp.getWriter().print("Welcome, you are in servlet!");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.print("Ты в Пост запросе");
}
}