I\'m working on a RESTful web service in Java. I need a good way to send error messages to the client if something\'s wrong.
According to the Javadoc, HttpServlet
HttpServlet
After your clarification, I tried this in Tomcat. Executing
response.sendError(HttpServletResponse.SC_BAD_REQUEST, "message goes here");
returns
HTTP/1.1 400 message goes here
as the first line in the response.
There must be a problem with the servlet container you are using.