What is the correct way of terminating a servlet that doesn't return any data to the client?
The purpose of the servlet in question is to recive some data from an Ajax request and fire off a TCP message to a piece of hardware to tell it to change it's state.
Do you have to specify a response at all?
I've opted for getting a reference to the Output stream and closing it, is this correct?
Should I send back a "hey that worked" message?
If you just want to provide a "success" status just return HTTP code 200. You don't have to return any stream since you just want to say "OK".
public void doGet(...) {
response.setStatus(HttpServletResponse.SC_OK);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With