/** * Apply the specified HTTP status code to the given response, if possible (that is, if not * executing within an include request). * * @param request current HTTP request * @param response current HTTP response * @param statusCode the status code to apply * @see #determineStatusCode * @see #setDefaultStatusCode * @see HttpServletResponse#setStatus */ protected void applyStatusCodeIfPossible( HttpServletRequest request, HttpServletResponse response, int statusCode) { if (!WebUtils.isIncludeRequest(request)) { if (logger.isDebugEnabled()) { logger.debug("Applying HTTP status code " + statusCode); } response.setStatus(statusCode); request.setAttribute(WebUtils.ERROR_STATUS_CODE_ATTRIBUTE, statusCode); } }
/** * Determine whether to use RequestDispatcher's <code>include</code> or <code>forward</code> * method. * * <p>Performs a check whether an include URI attribute is found in the request, indicating an * include request, and whether the response has already been committed. In both cases, an include * will be performed, as a forward is not possible anymore. * * @param request current HTTP request * @param response current HTTP response * @return <code>true</code> for include, <code>false</code> for forward * @see javax.servlet.RequestDispatcher#forward * @see javax.servlet.RequestDispatcher#include * @see javax.servlet.ServletResponse#isCommitted * @see org.springframework.web.util.WebUtils#isIncludeRequest */ protected boolean useInclude(HttpServletRequest request, HttpServletResponse response) { return (WebUtils.isIncludeRequest(request) || response.isCommitted()); }