Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] setStatus() vs. sendError(), custom error feedback

Hi all,

in our project, we are using Jetty for various HTTP services. If
anything goes wrong, we are currently using the following code to set
the status code and send a plain error message:

 HttpServletResponse res = ... (Jetty  response)
 res.setStatus(code);
 res.getOutputStream().write(message);

This approach fails if we add a GzipFilter to the Jetty context. I
have read that sendError() should be used for all kinds of error
messages, but it returns a pre-formatted HTML page, while we'd prefer
a plain text message (as e.g. our REST services doesn't return HTML
by default). I assume that attaching a custom error message is the
correct way of dealing with the issue, but I wanted to ask if there is
a more convenient way you would recommend? If no, how should such
an error handler look like? Is it the best approach to just copy and
paste the original Jetty sources of sendError() and modify the
contents?

Thanks for the attention,

Christian
BaseX Team


Back to the top