https://issues.apache.org/bugzilla/show_bug.cgi?id=56581

--- Comment #3 from Konstantin Kolinko <knst.koli...@gmail.com> ---
Looking into generated test_jsp.java,  I see that _jspService method ends with
the following:

[[[
    } catch (java.lang.Throwable t) {
      if (!(t instanceof javax.servlet.jsp.SkipPageException)){
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0)
          try { out.clearBuffer(); } catch (java.io.IOException e) {}
        if (_jspx_page_context != null)
_jspx_page_context.handlePageException(t);
        else throw new ServletException(t);
      }
    } finally {
]]]

So there is a call to JspWriterImpl.clearBuffer() that clears its buffer.

I can think of two ways to fix:
a) If I had access to JspWriterImpl internals then,

if (out.flushed)
 out.flushBuffer();
else
 out.clearBuffer();

The motivation is that if we cannot undo, then do not lose what we already have
generated.

I think this way is wrong. The underlying stream can have a larger buffer.
While out.flushed is true, the underlying stream may not have been flushed yet.

b) 
if (response.isCommitted()) {
 out.flush();
} else {
 out.clearBuffer();
}

Although "b)" is a bit more invasive, I think it is a way to go. It is also
good that it can be implemented using public APIs.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to