/** * Factory for creating instances of this class. * * @param request * @return instance of request contains forward attributes or {@code null} if it does not. */ public static ForwardAttributes of(HttpServletRequest request, String filterPrefix) { Args.notNull(request, "request"); final String requestUri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.FORWARD_REQUEST_URI, filterPrefix); final String servletPath = (String)request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); final String contextPath = (String)request.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); final String queryString = (String)request.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); final String pathInfo = (String)request.getAttribute(RequestDispatcher.FORWARD_PATH_INFO); if (!Strings.isEmpty(requestUri) || !Strings.isEmpty(servletPath) || !Strings.isEmpty(contextPath) || !Strings.isEmpty(queryString) || !Strings.isEmpty(pathInfo)) { return new ForwardAttributes(requestUri, servletPath, contextPath, queryString, pathInfo); } return null; }
@Override public boolean shouldPreserveClientUrl() { return (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri()) || forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())); } }
/** * Construct. * * @param httpServletRequest * @param filterPrefix * contentPath + filterPath, used to extract the actual {@link Url} * @param url */ public ServletWebRequest(HttpServletRequest httpServletRequest, String filterPrefix, Url url) { Args.notNull(httpServletRequest, "httpServletRequest"); Args.notNull(filterPrefix, "filterPrefix"); this.httpServletRequest = httpServletRequest; errorAttributes = ErrorAttributes.of(httpServletRequest, filterPrefix); forwardAttributes = ForwardAttributes.of(httpServletRequest, filterPrefix); this.filterPrefix = filterPrefix; if (url != null) { this.url = url; } else { this.url = getContextRelativeUrl(httpServletRequest.getRequestURI(), filterPrefix); } }
@Override public boolean shouldPreserveClientUrl() { return (errorAttributes != null && !Strings.isEmpty(errorAttributes.getRequestUri()) || forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())); } }
/** * Factory for creating instances of this class. * * @param request * @return instance of request contains forward attributes or {@code null} if it does not. */ public static ForwardAttributes of(HttpServletRequest request, String filterPrefix) { Args.notNull(request, "request"); final String requestUri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.FORWARD_REQUEST_URI, filterPrefix); final String servletPath = (String)request.getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH); final String contextPath = (String)request.getAttribute(RequestDispatcher.FORWARD_CONTEXT_PATH); final String queryString = (String)request.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING); final String pathInfo = (String)request.getAttribute(RequestDispatcher.FORWARD_PATH_INFO); if (!Strings.isEmpty(requestUri) || !Strings.isEmpty(servletPath) || !Strings.isEmpty(contextPath) || !Strings.isEmpty(queryString) || !Strings.isEmpty(pathInfo)) { return new ForwardAttributes(requestUri, servletPath, contextPath, queryString, pathInfo); } return null; }
/** * Construct. * * @param httpServletRequest * @param filterPrefix * contentPath + filterPath, used to extract the actual {@link Url} * @param url */ public ServletWebRequest(HttpServletRequest httpServletRequest, String filterPrefix, Url url) { Args.notNull(httpServletRequest, "httpServletRequest"); Args.notNull(filterPrefix, "filterPrefix"); this.httpServletRequest = httpServletRequest; errorAttributes = ErrorAttributes.of(httpServletRequest, filterPrefix); forwardAttributes = ForwardAttributes.of(httpServletRequest, filterPrefix); this.filterPrefix = filterPrefix; if (url != null) { this.url = url; } else { this.url = getContextRelativeUrl(httpServletRequest.getRequestURI(), filterPrefix); } }
return getContextRelativeUrl(problematicURI, filterPrefix); else if (forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())) String forwardURI = Url.parse(forwardAttributes.getRequestUri(), getCharset(), false) .toString(); return getContextRelativeUrl(forwardURI, filterPrefix);
return getContextRelativeUrl(problematicURI, filterPrefix); else if (forwardAttributes != null && !Strings.isEmpty(forwardAttributes.getRequestUri())) String forwardURI = Url.parse(forwardAttributes.getRequestUri(), getCharset(), false) .toString(); return getContextRelativeUrl(forwardURI, filterPrefix);