Source:
<code>public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { final String old_servlet_path = baseRequest.getServletPath(); final String old_path_info = baseRequest.getPathInfo(); final HttpServletMapping old_http_servlet_mapping = baseRequest.getHttpServletMapping(); DispatcherType type = baseRequest.getDispatcherType(); ServletHolder servletHolder = null; UserIdentity.Scope oldScope = null; MappedServletResource mapping = getMappedServlet(target); if (mapping != null) { servletHolder = mapping.getResource(); if (mapping.getPathSpec() != null) { PathSpec pathSpec = mapping.getPathSpec(); <START> String servletPath = pathSpec.getPathMatch(target); <END> String pathInfo = pathSpec.getPathInfo(target); HttpServletMapping httpServletMapping = mapping.getHttpServletMapping(servletPath); if (DispatcherType.INCLUDE.equals(type)) { baseRequest.setAttribute(RequestDispatcher.INCLUDE_SERVLET_PATH, servletPath); baseRequest.setAttribute(RequestDispatcher.INCLUDE_PATH_INFO, pathInfo); baseRequest.setAttribute(RequestDispatcher.INCLUDE_MAPPING, httpServletMapping); } else { baseRequest.setServletPath(servletPath); baseRequest.setPathInfo(pathInfo); baseRequest.setHttpServletMapping(httpServletMapping); } } } if (LOG.isDebugEnabled()) LOG.debug("servlet {}|{}|{} -> {}", baseRequest.getContextPath(), baseRequest.getServletPath(), baseRequest.getPathInfo(), servletHolder); try { oldScope = baseRequest.getUserIdentityScope(); baseRequest.setUserIdentityScope(servletHolder); nextScope(target, baseRequest, request, response); } finally { if (oldScope != null) baseRequest.setUserIdentityScope(oldScope); if (!(DispatcherType.INCLUDE.equals(type))) { baseRequest.setServletPath(old_servlet_path); baseRequest.setPathInfo(old_path_info); baseRequest.setHttpServletMapping(old_http_servlet_mapping); } } }</code><technical_language>Do need get pathSpec here? If so, get twice. get if</technical_language>

Target:
public void doScope(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { final ServletPathMapping old_servlet_path_mapping = baseRequest.getServletPathMapping(); DispatcherType type = baseRequest.getDispatcherType(); ServletHolder servletHolder = null; UserIdentity.Scope oldScope = null; MappedServlet mappedServlet = getMappedServlet(target); if (mappedServlet != null) { servletHolder = mappedServlet.getServletHolder(); ServletPathMapping servletPathMapping = mappedServlet.getServletPathMapping(target); if (servletPathMapping != null) { if (DispatcherType.INCLUDE.equals(type)) baseRequest.setAttribute(RequestDispatcher.INCLUDE_MAPPING, servletPathMapping); else baseRequest.setServletPathMapping(servletPathMapping); } } if (LOG.isDebugEnabled()) LOG.debug("servlet {}|{}|{}|{} -> {}", baseRequest.getContextPath(), baseRequest.getServletPath(), baseRequest.getPathInfo(), baseRequest.getHttpServletMapping(), servletHolder); try { oldScope = baseRequest.getUserIdentityScope(); baseRequest.setUserIdentityScope(servletHolder); nextScope(target, baseRequest, request, response); } finally { if (oldScope != null) baseRequest.setUserIdentityScope(oldScope); if (!(DispatcherType.INCLUDE.equals(type))) baseRequest.setServletPathMapping(old_servlet_path_mapping); } }