use of io.milton.http.Response in project lobcder by skoulouzis.
the class MiltonFilter method doMiltonProcessing.
private void doMiltonProcessing(HttpServletRequest req, HttpServletResponse resp) throws IOException {
// Do this part in its own try/catch block, because if there's a classpath
// problem it will probably be seen here
Request request;
Response response;
try {
request = new io.milton.servlet.ServletRequest(req, servletContext);
response = new io.milton.servlet.ServletResponse(resp);
} catch (Throwable e) {
// OK, I know its not cool to log AND throw. But we really want to log the error
// so it goes to the log4j logs, but we also want the container to handle
// the exception because we're outside the milton response handling framework
// So log and throw it is. But should never happen anyway...
log.error("Exception creating milton request/response objects", e);
throw new IOException("Exception creating milton request/response objects", e);
}
try {
MiltonServlet.setThreadlocals(req, resp);
httpManager.process(request, response);
} finally {
MiltonServlet.clearThreadlocals();
resp.getOutputStream().flush();
resp.flushBuffer();
}
}
use of io.milton.http.Response in project lobcder by skoulouzis.
the class MiltonServlet method service.
@Override
public void service(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) throws ServletException, IOException {
HttpServletRequest req = (HttpServletRequest) servletRequest;
HttpServletResponse resp = (HttpServletResponse) servletResponse;
try {
setThreadlocals(req, resp);
tlServletConfig.set(config.getServletConfig());
Request request = new ServletRequest(req, servletContext);
Response response = new ServletResponse(resp);
httpManager.process(request, response);
} finally {
clearThreadlocals();
tlServletConfig.remove();
ServletRequest.clearThreadLocals();
servletResponse.getOutputStream().flush();
servletResponse.flushBuffer();
}
}
Aggregations