users@jsr311.java.net

Re: JSR311 Response and corresponding message

From: Paul Sandoz <Paul.Sandoz_at_Sun.COM>
Date: Tue, 09 Sep 2008 15:38:37 +0200

On Sep 9, 2008, at 3:24 PM, Marc Hadley wrote:

> On Sep 9, 2008, at 6:08 AM, Paul Sandoz wrote:
>>>
>>> I just noticed that the sendError(int sc,String msg) method can
>>> customize an error code.
>>> It means that it is possible to have a header like that:
>>> HTTP/1.1 404 My custom message
>>>
>>
>> You are right. I just checked with a simple servlet implementation
>> and the "msg" parameter does indeed correspond to the reason phrase
>> on the status line.
>>
>> Drat! that is an oversight on our part.
>>
> That is incorrect behavior according to the Javadoc which says:

> "Sends an error response to the client using the specified status.
> 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", leaving cookies and other
> headers unmodified. If an error-page declaration has been made for
> the web application corresponding to the status code passed in, it
> will be served back in preference to the suggested msg parameter."
>
> I.e. the msg goes in the body, not the reason phrase.
>

Phew!

I double checked with the Servlet implementation in GF, it does both,
namely puts the message in the status line and embedded in some HTML
as a response entity. So this means you can put a really long message
in the status line, but it strips out \r\n :-)

Paul.