I'm sending data via post request from the webpage to the server.
$("#1, #2, #3, #4").on("click", function(){
console.log($(this).attr("id"));
var xhr = new XMLHttpRequest();
xhr.open("POST", "SimpleServlet.html", true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.send(JSON.stringify({"product_id": $(this).attr("id"), "quantity" : 1 }));
});
With the help of this javascript. I am sure that it gets sent to the server and it arrives there.
On the server I try to retrieve the values I wrote to the data.
.post("SimpleServlet.html", ctx ->
{
final Response response = ctx.getResponse();
System.out.println("Getting result");
final ExecResult<String> result = ExecHarness.yieldSingle(c ->
ctx.parse(String.class));
System.out.println("Getting value");
response.send("webshop.html");
})
I, unfortunately, didn't find any guide how to retrieve the String values accordingly.
I tried the above but this does get stuck inside the ExecHarness forever.
I would like get receive the values. Take them to make a new java object and then respond with the json of another java object back. (Second object depends on previous object data)