List of usage examples for javax.servlet RequestDispatcher INCLUDE_SERVLET_PATH
String INCLUDE_SERVLET_PATH
To view the source code for javax.servlet RequestDispatcher INCLUDE_SERVLET_PATH.
Click Source Link
From source file:org.ireland.jnetty.jsp.JspServletComposite.java
@Override public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String jspUri = request.getRequestURI(); if (jspUri == null) { // JSP specified via <jsp-file> in <servlet> declaration and supplied through // custom servlet container code jspUri = (String) request.getAttribute(Constants.JSP_FILE); }//from w ww .j a v a 2s.com if (jspUri == null) { /* * Check to see if the requested JSP has been the target of a RequestDispatcher.include() */ jspUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); if (jspUri != null) { /* * Requested JSP has been target of RequestDispatcher.include(). Its path is assembled from the relevant * javax.servlet.include.* request attributes */ String pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); if (pathInfo != null) { jspUri += pathInfo; } } else { /* * Requested JSP has not been the target of a RequestDispatcher.include(). Reconstruct its path from the * request's getServletPath() and getPathInfo() */ jspUri = request.getServletPath(); String pathInfo = request.getPathInfo(); if (pathInfo != null) { jspUri += pathInfo; } } } if (debug) { log.debug("JspEngine --> " + jspUri); log.debug("\t ServletPath: " + request.getServletPath()); log.debug("\t PathInfo: " + request.getPathInfo()); log.debug("\t RealPath: " + context.getRealPath(jspUri)); log.debug("\t RequestURI: " + request.getRequestURI()); log.debug("\t QueryString: " + request.getQueryString()); } try { boolean isPreCompile = isPreCompile(request); //??JSPServlet serviceJspFile(request, response, jspUri, isPreCompile); } catch (RuntimeException e) { throw e; } catch (ServletException e) { throw e; } catch (IOException e) { throw e; } catch (Throwable e) { ExceptionUtils.handleThrowable(e); throw new ServletException(e); } }
From source file:org.ireland.jnetty.webapp.RequestDispatcherImpl.java
private void doInclude(HttpServletRequest request, HttpServletResponse response, HttpInvocation invocation) throws ServletException, IOException { //Wrap the request IncludeRequest wrequest = new IncludeRequest(request, response, invocation); // If we have already been include previously, then keep using the established // original value. Otherwise, this is the first include and we need to establish the values. // Note: the established value on the original request for pathInfo and // for queryString is allowed to be null, but cannot be null for the other values. if (request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI) == null) { // ?Include, wrequest.setAttribute(RequestDispatcher.INCLUDE_REQUEST_URI, request.getRequestURI()); wrequest.setAttribute(RequestDispatcher.INCLUDE_CONTEXT_PATH, request.getContextPath()); wrequest.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, request.getServletPath()); wrequest.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, request.getPathInfo()); wrequest.setAttribute(RequestDispatcher.INCLUDE_QUERY_STRING, request.getQueryString()); }//from w ww . ja v a2 s . c o m boolean isValid = false; try { invocation.getFilterChainInvocation().service(wrequest, response); isValid = true; } finally { if (request.getAsyncContext() != null) { // An async request was started during the forward, don't close the // response as it may be written to during the async handling return; } // server/106r, ioc/0310 if (isValid) { finishResponse(response); } } }
From source file:org.massyframework.assembly.servlet.jasper.JasparResourceProessor.java
@Override public void process(HttpServletRequest req, HttpServletResponse resp, HttpResource resource) throws ServletException, IOException { Servlet servlet = this.getOrCreateJspServelt(resource); String path = resource.getName() + req.getPathInfo(); req.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, path); ClassLoader loader = ClassLoaderUtils .setThreadContextClassLoader(servlet.getServletConfig().getServletContext().getClassLoader()); try {//from w ww. ja v a2 s . c o m servlet.service(req, resp); } finally { ClassLoaderUtils.setThreadContextClassLoader(loader); } }
From source file:org.raptorjs.templating.rhino.servlet.RaptorTemplatesServlet.java
@Override protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String templateUri = (String) request.getAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH); if (templateUri != null) { /*/* w w w. j a v a 2 s. c om*/ * Requested template has been target of * RequestDispatcher.include(). Its path is assembled from the * relevant javax.servlet.include.* request attributes */ String pathInfo = (String) request.getAttribute(RequestDispatcher.INCLUDE_PATH_INFO); if (pathInfo != null) { templateUri += pathInfo; } } else { /* * Requested template has not been the target of a * RequestDispatcher.include(). Reconstruct its path from the * request's getServletPath() and getPathInfo() */ templateUri = request.getServletPath(); String pathInfo = request.getPathInfo(); if (pathInfo != null) { templateUri += pathInfo; } } if (log.isDebugEnabled()) { log.debug("Raptor Templating Enging --> " + templateUri); log.debug("\t ServletPath: " + request.getServletPath()); log.debug("\t PathInfo: " + request.getPathInfo()); log.debug("\t RealPath: " + context.getRealPath(templateUri)); log.debug("\t RequestURI: " + request.getRequestURI()); log.debug("\t QueryString: " + request.getQueryString()); } try { serviceRhtmlFile(request, response, templateUri); } catch (RuntimeException e) { throw e; } catch (ServletException e) { throw e; } catch (IOException e) { throw e; } catch (Throwable e) { throw new ServletException(e); } }