/* XXX: if we've already got an error, won't this just mask it?
if (responseStream.isCommitted())
throw new IllegalStateException("response can't sendError() after commit");
*/
WebApp webApp = getRequest().getWebApp();
ErrorPageManager errorManager = null;
if (webApp != null)
errorManager = webApp.getErrorPageManager();
else
errorManager = getRequest().getServer().getErrorPageManager();
setStatus(code, value);
try {
if (code == SC_NOT_MODIFIED || code == SC_NO_CONTENT) {
_response.finishInvocation();
return;
}
else if (errorManager != null) {
// server/10su
errorManager.sendError(_request, this, code, _statusMessage);
// _request.killKeepalive();
// close, but don't force a flush
// XXX: finish(false);
_response.finishInvocation();
return;
}
setContentType("text/html");
ServletOutputStream s = getOutputStream();
s.println("<html>");
if (! isCommitted()) {
s.print("<head><title>");
s.print(code);
s.print(" ");
s.print(_statusMessage);
s.println("</title></head>");
}
s.println("<body>");
s.print("<h1>");
s.print(code);
s.print(" ");
s.print(_statusMessage);
s.println("</h1>");
if (code == SC_NOT_FOUND) {
s.println(L.l("{0} was not found on this server.",
HTTPUtil.encodeString(getRequest().getPageURI())));
}
else if (code == SC_SERVICE_UNAVAILABLE) {
s.println(L.l("The server is temporarily unavailable due to maintenance downtime or excessive load."));
}
String version = null;
if (webApp == null) {
}
else if (webApp.getServer() != null
&& webApp.getServer().getServerHeader() != null) {
version = webApp.getServer().getServerHeader();
}
else if (CauchoSystem.isTesting()) {
}
else
version = VersionFactory.getFullVersion();