Section 5.2.1 Generating Response

The OneHandler embedded example shows how a simple handler may generate a response.

The normal servlet response API may be used and will typically set some status, content headers and the write out the content:

response.setContentType("text/html");
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().
println("<h1>Hello OneHandler</h1>");

It is also very important that a handler indicates completion of handling the request. The request should not be passed to other handlers:

Request base_request = (request instanceof Request) p(. ?(Request)request:HttpConnection.
getCurrentConnection().getRequest();

  • Currently 3.09/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
  Flag Inappropriate Content 0 comments