/** * Factory for creating instances of this class. * * @param request * @return instance of request contains error attributes or {@code null} if it does not. */ public static ErrorAttributes of(HttpServletRequest request, String filterPrefix) { Args.notNull(request, "request"); Integer code = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); String message = (String)request.getAttribute(RequestDispatcher.ERROR_MESSAGE); String uri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.ERROR_REQUEST_URI, filterPrefix); String servlet = (String)request.getAttribute(RequestDispatcher.ERROR_SERVLET_NAME); @SuppressWarnings("unchecked") Class<? extends Throwable> type = (Class<? extends Throwable>)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE); Throwable ex = (Throwable)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); if (!Strings.isEmpty(uri) || code != null || ex != null) { return new ErrorAttributes(code, message, uri, servlet, type, ex); } return null; }
/** * Factory for creating instances of this class. * * @param request * @return instance of request contains error attributes or {@code null} if it does not. */ public static ErrorAttributes of(HttpServletRequest request, String filterPrefix) { Args.notNull(request, "request"); Integer code = (Integer)request.getAttribute(RequestDispatcher.ERROR_STATUS_CODE); String message = (String)request.getAttribute(RequestDispatcher.ERROR_MESSAGE); String uri = DispatchedRequestUtils.getRequestUri(request, RequestDispatcher.ERROR_REQUEST_URI, filterPrefix); String servlet = (String)request.getAttribute(RequestDispatcher.ERROR_SERVLET_NAME); @SuppressWarnings("unchecked") Class<? extends Throwable> type = (Class<? extends Throwable>)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION_TYPE); Throwable ex = (Throwable)request.getAttribute(RequestDispatcher.ERROR_EXCEPTION); if (!Strings.isEmpty(uri) || code != null || ex != null) { return new ErrorAttributes(code, message, uri, servlet, type, ex); } return null; }
/** * 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; }
/** * 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; }