/** * Return the servlet path for the given request, regarding an include request * URL if called within a RequestDispatcher include. * <p>As the value returned by {@code request.getServletPath()} is already * decoded by the servlet container, this method will not attempt to decode it. * @param request current HTTP request * @return the servlet path */ public String getServletPath(HttpServletRequest request) { String servletPath = (String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE); if (servletPath == null) { servletPath = request.getServletPath(); } if (servletPath.length() > 1 && servletPath.endsWith("/") && shouldRemoveTrailingServletPathSlash(request)) { // On WebSphere, in non-compliant mode, for a "/foo/" case that would be "/foo" // on all other servlet containers: removing trailing slash, proceeding with // that remaining slash as final lookup path... servletPath = servletPath.substring(0, servletPath.length() - 1); } return servletPath; }
/** * Return the servlet path for the given request, regarding an include request * URL if called within a RequestDispatcher include. * <p>As the value returned by {@code request.getServletPath()} is already * decoded by the servlet container, this method will not attempt to decode it. * @param request current HTTP request * @return the servlet path */ public String getServletPath(HttpServletRequest request) { String servletPath = (String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE); if (servletPath == null) { servletPath = request.getServletPath(); } if (servletPath.length() > 1 && servletPath.endsWith("/") && shouldRemoveTrailingServletPathSlash(request)) { // On WebSphere, in non-compliant mode, for a "/foo/" case that would be "/foo" // on all other servlet containers: removing trailing slash, proceeding with // that remaining slash as final lookup path... servletPath = servletPath.substring(0, servletPath.length() - 1); } return servletPath; }
/** * Return the servlet path for the given request, regarding an include request * URL if called within a RequestDispatcher include. * <p>As the value returned by {@code request.getServletPath()} is already * decoded by the servlet container, this method will not attempt to decode it. * @param request current HTTP request * @return the servlet path */ public String getServletPath(HttpServletRequest request) { String servletPath = (String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE); if (servletPath == null) { servletPath = request.getServletPath(); } if (servletPath.length() > 1 && servletPath.endsWith("/") && shouldRemoveTrailingServletPathSlash(request)) { // On WebSphere, in non-compliant mode, for a "/foo/" case that would be "/foo" // on all other servlet containers: removing trailing slash, proceeding with // that remaining slash as final lookup path... servletPath = servletPath.substring(0, servletPath.length() - 1); } return servletPath; }
/** * Return the servlet path for the given request, regarding an include request * URL if called within a RequestDispatcher include. * <p>As the value returned by {@code request.getServletPath()} is already * decoded by the servlet container, this method will not attempt to decode it. * @param request current HTTP request * @return the servlet path */ public String getServletPath(HttpServletRequest request) { String servletPath = (String) request.getAttribute(WebUtils.INCLUDE_SERVLET_PATH_ATTRIBUTE); if (servletPath == null) { servletPath = request.getServletPath(); } if (servletPath.length() > 1 && servletPath.endsWith("/") && shouldRemoveTrailingServletPathSlash(request)) { // On WebSphere, in non-compliant mode, for a "/foo/" case that would be "/foo" // on all other servlet containers: removing trailing slash, proceeding with // that remaining slash as final lookup path... servletPath = servletPath.substring(0, servletPath.length() - 1); } return servletPath; }