[JENKINS-20074] Do not try to close the response writer after calling sendError; it may already have been set to a stream.
Allows the underlying error to be properly displayed (second problem):
ServletException: This page expects a form submission but had only {delay=[0sec]}