Tomcat Process sendError
1
2
3
4
5
6
7
8
9
// Tomcat still return full HTML thing.
response.sendError(((CustomizedException) ex).getHttpStatusCode(), ex.getMessage());
return;
// Adopt this:
response.setStatus(((CustomizedException) ex).getHttpStatusCode()); // 409
response.setContentType("text/plain;charset=UTF-8");
response.getWriter().write(ex.getMessage()); // E0002
return;
This post is licensed under CC BY 4.0 by the author.