Ok so I have a pretty simple webapp using a Servlet and in some cases I send and error back to the client like:
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Did not specify parameter xyz");
This works fine in general but Tomcat(6.0.33 and Java 1.6.0_26-b03) does not show the given error message from above.
If I run the application on a different container like glassfish the given message is shown.
So, example output ....
Tomcat:
400 - Bad Request
Glassfish:
400 - Did not specify parameter xyz
Is it possible to configure tomcat to behave in the same way?
Ok after some more digging I found the solution here: How to properly send an HTTP message to the client
You need to set:
org.apache.coyote.USE_CUSTOM_STATUS_MSG_IN_HEADER = true
in /conf/catalina.properties
This causes tomcat to send the error message you set in the headers 'properly' :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With