JETTY-1501 Setting custom error response message changes page title

This commit is contained in:
Jan Bartel 2012-08-03 19:22:58 +10:00
parent 3f07564274
commit 7b61f5f04d
1 changed files with 24 additions and 3 deletions

View File

@ -37,6 +37,7 @@ import org.eclipse.jetty.util.ByteArrayISO8859Writer;
public class ErrorHandler extends AbstractHandler
{
boolean _showStacks=true;
boolean _showMessageInTitle=true;
String _cacheControl="must-revalidate,no-cache,no-store";
/* ------------------------------------------------------------ */
@ -89,8 +90,12 @@ public class ErrorHandler extends AbstractHandler
writer.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\"/>\n");
writer.write("<title>Error ");
writer.write(Integer.toString(code));
if (_showMessageInTitle)
{
writer.write(' ');
write(writer,message);
}
writer.write("</title>\n");
}
@ -177,6 +182,22 @@ public class ErrorHandler extends AbstractHandler
_showStacks = showStacks;
}
/* ------------------------------------------------------------ */
/**
* @param showMessageInTitle if true, the error message appears in page title
*/
public void setShowMessageInTitle(boolean showMessageInTitle)
{
_showMessageInTitle = showMessageInTitle;
}
/* ------------------------------------------------------------ */
public boolean getShowMessageInTitle()
{
return _showMessageInTitle;
}
/* ------------------------------------------------------------ */
protected void write(Writer writer,String string)
throws IOException