I am using the embedded version of jetty. I have noticed the following:
in the handler method, if I want to directly respond with an HTTP OK response, then sleep for x seconds, the handler is doing the opposite. Is this normal?
the handle function is the following:
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
response.setContentType("text/html;charset=utf-8");
response.setStatus(HttpServletResponse.SC_OK);
baseRequest.setHandled(true);
response.getWriter().println("OK");
Thread.sleep(10000);
}
The bastard is sleeping 10 seconds then returning the response, why is this happening?
You need to call
before you sleep the Thread.
From the JavaDoc of this method: