@Override public void include(String path) throws ServletException, IOException { this.request.getRequestDispatcher(path).include(this.request, this.response); }
@Override public void include(String path, boolean flush) throws ServletException, IOException { this.request.getRequestDispatcher(path).include(this.request, this.response); if (flush) { this.response.flushBuffer(); } }
/** * Include page which path relative to the root of the ServletContext. */ public static boolean includeAbsolute(final ServletContext context, final ServletRequest request, final HttpServletResponse response, final String page) throws IOException, ServletException { RequestDispatcher dispatcher = context.getRequestDispatcher(page); if (dispatcher != null) { dispatcher.include(request, response); return true; } return false; }
@Override public void include(String path) throws ServletException, IOException { this.request.getRequestDispatcher(path).include(this.request, this.response); }
@Override public void include(String path, boolean flush) throws ServletException, IOException { this.request.getRequestDispatcher(path).include(this.request, this.response); if (flush) { this.response.flushBuffer(); } }
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) { request.setCharacterEncoding("utf-8"); } response.setContentType("text/html; charset=UTF-8"); this.getServletContext().getRequestDispatcher("/header.jsp"). include(request, response); addResults(request, response); this.getServletContext().getRequestDispatcher("/footer.jsp"). include(request, response); }
/** * Include page which path is relative to the current HTTP request. */ public static boolean include(final ServletRequest request, final ServletResponse response, final String page) throws IOException, ServletException { RequestDispatcher dispatcher = request.getRequestDispatcher(page); if (dispatcher != null) { dispatcher.include(request, response); return true; } return false; }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) { request.setCharacterEncoding("utf-8"); } response.setContentType("text/html; charset=UTF-8"); this.getServletContext().getRequestDispatcher("/header.jsp"). include(request, response); addResults(request, response); this.getServletContext().getRequestDispatcher("/footer.jsp"). include(request, response); }
/** * Include named resource. */ public static boolean includeNamed(final ServletContext context, final ServletRequest request, final ServletResponse response, final String page) throws IOException, ServletException { RequestDispatcher dispatcher = context.getNamedDispatcher(page); if (dispatcher != null) { dispatcher.include(request, response); return true; } return false; }
@Override protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception { ServletContext servletContext = getServletContext(); Assert.state(servletContext != null, "No ServletContext"); RequestDispatcher rd = servletContext.getNamedDispatcher(this.servletName); if (rd == null) { throw new ServletException("No servlet with name '" + this.servletName + "' defined in web.xml"); } // If already included, include again, else forward. if (useInclude(request, response)) { rd.include(request, response); if (logger.isTraceEnabled()) { logger.trace("Included servlet [" + this.servletName + "] in ServletForwardingController '" + this.beanName + "'"); } } else { rd.forward(request, response); if (logger.isTraceEnabled()) { logger.trace("Forwarded to servlet [" + this.servletName + "] in ServletForwardingController '" + this.beanName + "'"); } } return null; }
@Override public void include(String url) throws ServletException, IOException { jspOut.flush(); request.getRequestDispatcher(url).include(request, response); }
@Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { if (request.getCharacterEncoding() == null) { request.setCharacterEncoding("utf-8"); } response.setContentType("text/html; charset=UTF-8"); this.getServletContext().getRequestDispatcher("/header.jsp"). include(request, response); request.setAttribute("classifiers", classifiers); this.getServletContext().getRequestDispatcher("/ner.jsp"). include(request, response); addResults(request, response); this.getServletContext().getRequestDispatcher("/footer.jsp"). include(request, response); }
@Override public void include(String url, boolean flush) throws ServletException, IOException { if (flush) { jspOut.flush(); } final PrintWriter pw = new PrintWriter(jspOut); request.getRequestDispatcher(url).include(request, new HttpServletResponseWrapper(response) { @Override public PrintWriter getWriter() { return pw; } @Override public ServletOutputStream getOutputStream() { throw new UnsupportedOperationException("JSP-included resource must use getWriter()"); } }); pw.flush(); }
public void include(String path) throws ServletException, IOException { HttpServletRequest request = (HttpServletRequest) super.getVariable("request"); HttpServletResponse response = (HttpServletResponse) super.getVariable("response"); RequestDispatcher dispatcher = request.getRequestDispatcher(path); dispatcher.include(request, response); }
/** {@inheritDoc} */ @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { final String resource = request.getParameter("resource"); if (resource != null && customResources.get(resource) != null) { final String customResource = customResources.get(resource); final HttpServletResponse httpResponse = (HttpServletResponse) response; MonitoringController.addHeadersForResource(httpResponse, customResource); if (customResources.get("useForward") == null) { request.getRequestDispatcher(customResource).include(request, response); } else { request.getRequestDispatcher(customResource).forward(request, response); } } else { chain.doFilter(request, response); } }
/** * Renders the view by dispatching to the target JSP. */ @Override protected void renderView(final ActionRequest actionRequest, final String target) throws Exception { HttpServletRequest request = actionRequest.getHttpServletRequest(); HttpServletResponse response = actionRequest.getHttpServletResponse(); RequestDispatcher dispatcher = request.getRequestDispatcher(target); if (dispatcher == null) { response.sendError(SC_NOT_FOUND, "Result not found: " + target); // should never happened return; } // If we're included, then include the view, otherwise do forward. // This allow the page to, for example, set content type. if (DispatcherUtil.isPageIncluded(request, response)) { dispatcher.include(request, response); } else { dispatcher.forward(request, response); } }
logger.debug("Including [" + getUrl() + "]"); rd.include(request, response);
d.include(req,rsp);
@Override public void doFilter(HttpServletRequest wrappedRequest, HttpServletResponse wrappedResponse) throws IOException, ServletException { String id = wrappedRequest.getSession().getId(); wrappedRequest.getRequestDispatcher("/").include(wrappedRequest, wrappedResponse); assertThat( SessionRepositoryFilterTests.this.sessionRepository.findById(id)) .isNotNull(); } });
private void doTestServletForwardingController(ServletForwardingController sfc, boolean include) throws Exception { HttpServletRequest request = mock(HttpServletRequest.class); HttpServletResponse response = mock(HttpServletResponse.class); ServletContext context = mock(ServletContext.class); RequestDispatcher dispatcher = mock(RequestDispatcher.class); given(request.getMethod()).willReturn("GET"); given(context.getNamedDispatcher("action")).willReturn(dispatcher); if (include) { given(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).willReturn("somePath"); } else { given(request.getAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE)).willReturn(null); } StaticWebApplicationContext sac = new StaticWebApplicationContext(); sac.setServletContext(context); sfc.setApplicationContext(sac); assertNull(sfc.handleRequest(request, response)); if (include) { verify(dispatcher).include(request, response); } else { verify(dispatcher).forward(request, response); } }