users@jsr311.java.net

Re: JSR311 Response and corresponding message

From: Marc Hadley <Marc.Hadley_at_Sun.COM>
Date: Tue, 09 Sep 2008 09:24:52 -0400

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.

Marc.

>
>>
>> On Wed, Sep 3, 2008 at 7:06 PM, Marc Hadley <Marc.Hadley_at_sun.com>
>> wrote:
>> No, currently that is not possible. We did discuss this but since
>> there's no way to set the status message for runtimes based on the
>> Servlet container there seemed no point in adding it to the JSR 311
>> API.
>>
>> Marc.
>>
>>
>> On Sep 3, 2008, at 12:48 PM, Denis wrote:
>>
>> Hi all,
>>
>> Is it possible to specify a message with a Response status code?
>> For instance, if I see the header of the response, I would like to
>> see:
>> 200 Good Response
>> 400 Too bad
>> ...
>>
>> Thanks for your help
>>
>> Denis
>>
>> ---
>> Marc Hadley <marc.hadley at sun.com>
>> CTO Office, Sun Microsystems.
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jsr311.dev.java.net
>> For additional commands, e-mail: users-help_at_jsr311.dev.java.net
>>
>>
>

---
Marc Hadley <marc.hadley at sun.com>
CTO Office, Sun Microsystems.