OK, that
makes sense. In my case, I have exceptions mapped to an error page
that will format a nice error page so the response is sent as an HTTP
200 instead of the standard HTTP 500. I suppose it is possible that
the committed response is not an HTTP 200 either....
Does it make sense for Jetty to try to compromise and get the content
type of the error response and send it along if it matches the
committed response? I could see issues if you tried to put text/html
into a failed image/png response, for example.
Tony
Joakim Erdfelt wrote:
Once you flush the writer the response is committed to the
client.
A committed response also results in the HTTP response header
being sent.
A response is of the following format ...
HTTP Status Code + Status Message + HTTP Version
HTTP Response Headers
HTTP Response Data
In your flush example, you are forcing the HTTP Status Code line
and the HTTP response headers to be sent just so that some of your data
can be flushed.
If you throw an exception after it is committed it is too late
to send an error response header. (Such as a 3xx, 4xx or 5xx codes)
- Joakim
On Mon, May 10, 2010 at 1:31 PM, Tony
Thompson <Tony.Thompson@xxxxxxxxxxxxxx>
wrote:
I
have a
simple servlet that generates some HTML output, flushes
response.getWriter() (response is committed) and then throws a
ServletException to simulate an error. In this situation, Jetty 7.1
seems to eat the exception and never goes into error handling. So, in
the browser, I get the HTML before the exception and it just stops. If
I don't flush the PrintWriter, error handling works as expected.
In Jetty 5, I would get the HTML before the exception and the exception
all in the same page. Sometimes it would be ugly but, at least I still
got the error back. What is the correct way of handling a situation
like this? I prefer to get the exception back in the browser. Can
this be configured somewhere?
Thanks
Tony
This message
(and any associated files) is intended only for the
use of the individual or entity to which it is addressed and may
contain information that is confidential, subject to copyright or
constitutes a trade secret. If you are not the intended recipient
you are hereby notified that any dissemination, copying or
distribution of this message, or files associated with this message,
is strictly prohibited. If you have received this message in error,
please notify us immediately by replying to the message and deleting
it from your computer. Messages sent to and from Stoneware, Inc.
may be monitored.
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users
This message (and any associated files) is intended only for the use of the individual or entity to which it is addressed and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not the intended recipient you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Messages sent to and from Stoneware, Inc. may be monitored.
|