Search in sources :

Example 6 with Response

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();
    }
}
Also used : HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(io.milton.http.Response) javax.servlet(javax.servlet) Request(io.milton.http.Request) HttpServletRequest(javax.servlet.http.HttpServletRequest) IOException(java.io.IOException)

Example 7 with Response

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();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) Response(io.milton.http.Response) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(io.milton.http.Request) HttpServletResponse(javax.servlet.http.HttpServletResponse)

Aggregations

Request (io.milton.http.Request)7 Response (io.milton.http.Response)7 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 HttpServletResponse (javax.servlet.http.HttpServletResponse)5 ServletRequest (javax.servlet.ServletRequest)2 ServletResponse (javax.servlet.ServletResponse)2 AccessControlList (io.milton.annotations.AccessControlList)1 Auth (io.milton.http.Auth)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 javax.servlet (javax.servlet)1 Timer (org.polymap.core.runtime.Timer)1 DefaultSessionContextProvider (org.polymap.core.runtime.session.DefaultSessionContextProvider)1