0

Some third party is sending an Http Post request whenever something changes in their DB (e.g. when a contact has been updated, they send the contactID and 'contact_updated'). I have build a socket listener that catches those requests and is able to parse the information. However, I just can't get it to work to send back a response with the status '200 - OK'. Thus, the server on the client side keeps on trying (four times or so) to re-send the request.

Is there any, simple way to just send the response status without the need of adding external libs etc.?

2 Answers2

0

It should be enough to send the string HTTP/1.1 200 OK back in your socket-listener. If you have troubles, you can check out this answer, it shows how to use a HttpServer in Java just via plain JavaSE features.

Halko Karr-Sajtarevic
  • 2,248
  • 1
  • 16
  • 14
0

Use

response.setStatus(HttpServletResponse.SC_OK);

to set the status code in your response header.


You may also set the content type.

response.setContentType("text/html;charset=UTF-8");
Roshana Pitigala
  • 8,437
  • 8
  • 49
  • 80