Index: web/web-core/src/main/java/org/apache/catalina/connector/Response.java =================================================================== --- web/web-core/src/main/java/org/apache/catalina/connector/Response.java (revision 24039) +++ web/web-core/src/main/java/org/apache/catalina/connector/Response.java (working copy) @@ -1359,6 +1359,35 @@ // END RIMOD 4642650 setStatus(SC_FOUND); setHeader("Location", absolute); + + // According to RFC2616 section 10.3.3 302 Found, + // the response SHOULD contain a short hypertext note with + // a hyperlink to the new URI. + setContentType("text/html"); + setLocale(Locale.getDefault()); + + String href = RequestUtil.filter(absolute); + StringBuilder sb = new StringBuilder(150 + href.length()); + + sb.append("\r\n"); + sb.append("Document moved\r\n"); + sb.append("

Document moved

\r\n"); + sb.append("This document has moved here.

\r\n"); + sb.append("\r\n"); + sb.append("\r\n"); + + try { + getWriter().write(sb.toString()); + } catch (IllegalStateException ise1) { + try { + getOutputStream().print(sb.toString()); + } catch (IllegalStateException ise2) { + // ignore; the RFC says "SHOULD" so it is acceptable + // to omit the body in case of an error + } + } } catch (IllegalArgumentException e) { setStatus(SC_NOT_FOUND); }