class EverrestServlet extends HttpServlet {

    @Override
    public void service(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException {
        EnvironmentContext env = new EnvironmentContext();
        env.put(HttpServletRequest.class, httpRequest);
        env.put(HttpServletResponse.class, httpResponse);
        env.put(ServletConfig.class, getServletConfig());
        env.put(ServletContext.class, getServletContext());
        env.put(WebApplicationDeclaredRoles.class, webApplicationRoles);
        env.put(ErrorPages.class, errorPages);
        try {
            ServletContainerRequest request = ServletContainerRequest.create(httpRequest);
            ContainerResponse response = new ContainerResponse(new ServletContainerResponseWriter(httpResponse));
            processor.process(request, response, env);
        } catch (IOException ioe) {
            // Met problem with Acrobat Reader HTTP client when use EverRest for WebDav.
            // Client close connection before all data transferred and it cause error on server side.
            if (ioe.getClass().getName().equals("org.apache.catalina.connector.ClientAbortException")) {
                LOG.debug(ioe.getMessage(), ioe);
            } else {
                throw ioe;
            }
        } catch (UnhandledException e) {
            LOG.error(e.getMessage(), e);
            if (e.getResponseStatus() != 0) {
                httpResponse.sendError(e.getResponseStatus());
            } else {
                throw new ServletException(e.getCause());
            }
        } catch (Throwable e){
            LOG.debug(e.getLocalizedMessage(), e);
            throw e;
        }
    }

}