I currently have a client -> server model where the client periodically pushes data. I am using Jersey with servlets on the server to respond to the incoming requests.
Since this is a data synchronization step, once the data gets received by the server, an OK message needs to be returned to the client.
As a test, I made a path the server handles as "/testResponse" where all it does is this:
@GET
@Path("/testResponse")
@Produces(MediaType.TEXT_PLAIN)
public String GET_testResponse() {
System.out.println("Received test request...");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("Returning response...");
return "message received!";
}
What I wanted to test is I initiate the request from my client, but then while the client is waiting 5 seconds, the client exits the request, simulating it disconnecting from wireless. After those 5 seconds are up, the server returns the message (with no error being thrown).
My question I guess is simple: Is there any way for the server to know if the client received the response since no exceptions were thrown etc? Should an error be thrown when you try to handle the response? I know outside of jersey, you can use the HttpServletResponse method to actually respond before the function exits, so I'm wondering if I'd need something like that.
Thanks!