On 23/11/2012 21:09, Michael-O wrote:
> Hi,
> 
> I've been struggling recently with this builtin valve and some
> Spring-based REST services. I some cases I do return states like 404 or
> 400. SendError seems to be the right thing to do but Tomcat alters the
> response with the HTML page. Which is highly unwanted for a REST API.
> 
> I have checked Oracle's original JavaDocs for #sendError(int) + Servlet
> Spec 2.5 and 3.0 all three of them, do not explicitly mention that an
> error HTML response is returned with this method. The JavaDoc [1] says:
> "...If an error-page declaration has been made for the web application
> corresponding to the status code passed in, it will be served back the
> error page..."
> 
> I did not define a custom error page.
> 
> Where as the #sendError(int,String) says:
> "... The server defaults to creating the response to look like an
> HTML-formatted server error page containing the specified message,
> setting the content type to "text/html"."
> 
> This one is crystal clear.
> sendError(int) simply calls sendError(int,String) with a null string arg.
> 
> Am I misunderstanding the the definition? Should I avoid sendError
> alltogher and resort to setStatus? What would be the implications?
> I do know that sendError commits and closes the response immediately.
> 
> A clarification is highly appreciated.

Use Tomcat 7 and define a custom, default error page. You'll then remain
in complete control of the error response.

Mark


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to