@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };
private void dispatchRequest(final HttpServerExchange exchange, final ServletRequestContext servletRequestContext, final ServletChain servletChain, final DispatcherType dispatcherType) throws Exception { servletRequestContext.setDispatcherType(dispatcherType); servletRequestContext.setCurrentServlet(servletChain); if (dispatcherType == DispatcherType.REQUEST || dispatcherType == DispatcherType.ASYNC) { firstRequestHandler.call(exchange, servletRequestContext); } else { next.handleRequest(exchange); } }
private void dispatchRequest(final HttpServerExchange exchange, final ServletRequestContext servletRequestContext, final ServletChain servletChain, final DispatcherType dispatcherType) throws Exception { HttpHandler next=null; try{ //lets get access of superclass private fields using reflection: Field nextField = ServletInitialHandler.class.getDeclaredField("next"); nextField.setAccessible(true); next = (HttpHandler)nextField.get(this); nextField.setAccessible(false); }catch(NoSuchFieldException | IllegalAccessException e){ throw new ServletException(e); } servletRequestContext.setDispatcherType(dispatcherType); servletRequestContext.setCurrentServlet(servletChain); if (dispatcherType == DispatcherType.REQUEST || dispatcherType == DispatcherType.ASYNC) { super.handleFirstRequest(exchange, servletChain, servletRequestContext, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse()); } else { next.handleRequest(exchange); } }
private void dispatchRequest(final HttpServerExchange exchange, final ServletRequestContext servletRequestContext, final ServletChain servletChain, final DispatcherType dispatcherType) throws Exception { HttpHandler next=null; try{ //lets get access of superclass private fields using reflection: Field nextField = ServletInitialHandler.class.getDeclaredField("next"); nextField.setAccessible(true); next = (HttpHandler)nextField.get(this); nextField.setAccessible(false); }catch(NoSuchFieldException | IllegalAccessException e){ throw new ServletException(e); } servletRequestContext.setDispatcherType(dispatcherType); servletRequestContext.setCurrentServlet(servletChain); if (dispatcherType == DispatcherType.REQUEST || dispatcherType == DispatcherType.ASYNC) { super.handleFirstRequest(exchange, servletChain, servletRequestContext, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse()); } else { next.handleRequest(exchange); } }
@Override public void dispatchToServlet(final HttpServerExchange exchange, final ServletChain servletchain, final DispatcherType dispatcherType) throws Exception { final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); DispatcherType oldDispatch = servletRequestContext.getDispatcherType(); ServletChain oldChain = servletRequestContext.getCurrentServlet(); try { dispatchRequest(exchange, servletRequestContext, servletchain, dispatcherType); } finally { servletRequestContext.setDispatcherType(oldDispatch); servletRequestContext.setCurrentServlet(oldChain); } }
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { String old = exchange.getAttachment(OLD_RELATIVE_PATH); if(!old.equals(exchange.getRelativePath())) { ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY); ServletPathMatch info = src.getDeployment().getServletPaths().getServletHandlerByPath(exchange.getRelativePath()); src.setCurrentServlet(info.getServletChain()); src.setServletPathMatch(info); } handler.handleRequest(exchange); } };