@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { this.delegateServlet.service(request, response); }
@Override @Nullable public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { ((Servlet) handler).service(request, response); return null; }
/** * Invoke the wrapped Servlet instance. * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Assert.state(this.servletInstance != null, "No Servlet instance"); this.servletInstance.service(request, response); return null; }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { this.delegateServlet.service(request, response); }
/** * Pass the call on to the Filter/Servlet. */ @Override public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException { if (this.filter != null) { this.filter.doFilter(request, response, this.nextFilterChain); } else { Assert.state(this.servlet != null, "Neither a Filter not a Servlet set"); this.servlet.service(request, response); } }
@Override public void service(ServletRequest req, ServletResponse res) throws ServletException, IOException { wrappedServlet.service(req, res); }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { this.delegateServlet.service(request, response); }
@Override @Nullable public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { ((Servlet) handler).service(request, response); return null; }
/** * Invoke the wrapped Servlet instance. * @see javax.servlet.Servlet#service(javax.servlet.ServletRequest, javax.servlet.ServletResponse) */ @Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { Assert.state(this.servletInstance != null, "No Servlet instance"); this.servletInstance.service(request, response); return null; }
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { this.invoked = true; if (this.servlet != null) { this.servlet.service(request, response); } else { chain.doFilter(request, response); } }
/** * Pass the call on to the Filter/Servlet. */ @Override public void doFilter(ServletRequest request, ServletResponse response) throws ServletException, IOException { if (this.filter != null) { this.filter.doFilter(request, response, this.nextFilterChain); } else { Assert.state(this.servlet != null, "Neither a Filter not a Servlet set"); this.servlet.service(request, response); } }
servlet.service(request, response); } else { RequestDispatcher rd = configImpl.getServletContext().getNamedDispatcher("default");
@Override public void handle(Request baseRequest, ServletRequest request, ServletResponse response) throws ServletException, IOException { final boolean asyncSupported = baseRequest.isAsyncSupported(); if (!isAsyncSupported()) { baseRequest.setAsyncSupported(false, null); } try { servlet.service(request, response); } catch (EofException ignored) { // Want to ignore the EofException as this signifies the client has disconnected or the // response has already been written. The problem with using an ExceptionMapper is that // we don't actually want to write a response given that the connection has already been // closed } finally { baseRequest.setAsyncSupported(asyncSupported, null); } } }
@Test public void doFilterWithServlet() throws Exception { Servlet servlet = mock(Servlet.class); MockFilterChain chain = new MockFilterChain(servlet); chain.doFilter(this.request, this.response); verify(servlet).service(this.request, this.response); try { chain.doFilter(this.request, this.response); fail("Expected Exception"); } catch (IllegalStateException ex) { assertEquals("This FilterChain has already been called!", ex.getMessage()); } }
@Override public void service( ServletRequest servletRequest, ServletResponse servletResponse) throws IOException, ServletException { servlet.service(servletRequest, servletResponse); }
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { controller.service(request, response); return null; } }
@Test public void testProfileServlet() throws Exception { Servlet servlet = new DispatcherServlet(); final CallStackElement total = Profiler.activateProfiling("total"); servlet.service(new MockHttpServletRequest(), new MockHttpServletResponse()); Profiler.stop(); final CallStackElement serviceCall = total.getChildren().iterator().next(); assertEquals("FrameworkServlet#service", serviceCall.getShortSignature()); }
servlet.init(new MockServletConfig(servletContext, "myHandler")); servlet.service(request, response); assertEquals("myResponse", response.getContentAsString()); servlet.service(request, response); fail("Should have thrown ServletException"); servlet.service(request, response); fail("Should have thrown IOException");
@Test public void doFilterWithServletAndFilters() throws Exception { Servlet servlet = mock(Servlet.class); MockFilter filter2 = new MockFilter(servlet); MockFilter filter1 = new MockFilter(null); MockFilterChain chain = new MockFilterChain(servlet, filter1, filter2); chain.doFilter(this.request, this.response); assertTrue(filter1.invoked); assertTrue(filter2.invoked); verify(servlet).service(this.request, this.response); try { chain.doFilter(this.request, this.response); fail("Expected Exception"); } catch (IllegalStateException ex) { assertEquals("This FilterChain has already been called!", ex.getMessage()); } }
@Test public void testDontProfileStagemonitorServlet() throws Exception { Servlet servlet = new StagemonitorFileServlet(); final CallStackElement total = Profiler.activateProfiling("total"); servlet.service(new MockHttpServletRequest(), new MockHttpServletResponse()); Profiler.stop(); assertEquals(0, total.getChildren().size()); } }