By default, Tomcat sends some HTML content back to the client if it encounters something like an HTTP 404. I know that via web.xml
an
Though this question is a bit old, I ran into this problem too. First of all, Tomcat's behavior is absolutely correct. This is per Servlet Spec. One should not alter Tomcat's behavior against the spec. As Heikki Vesalainen and mrCoder mentioned, use setStatus
and setStatus
only.
To whom it may concern, I have raised a ticket with Tomcat to improve the docs of sendError
.