jsr369-experts@servlet-spec.java.net

[jsr369-experts] Re: return of ServletContext#getRequestCharacterEncoding, #getResponseCharacterEncoding

From: Shing Wai Chan <shing.wai.chan_at_oracle.com>
Date: Fri, 3 Mar 2017 09:32:46 -0800

> On Mar 3, 2017, at 1:00 AM, Mark Thomas <markt_at_apache.org> wrote:
>
> On 02/03/17 00:43, Shing Wai Chan wrote:
>> In the following, we will consider the case where the encoding is not specified.
>>
>> In ServletRequest#getCharacterEncoding, it returns null.
>> In ServletResponse#getCharacterEncoding, it returns ISO-8859-1.
>>
>> I plan to keep the same behaviors in ServletContext API as follows:
>> ServletContext#getRequestCharacterEncoding, it returns null
>> ServletContext#getResponseCharacterEncoding, it returns ISO-8859-1
>>
>> If there is any comment, please let me know.
>
> I think ServletContext#getResponseCharacterEncoding should return null
> if it is not set.

I have a second thought on this.
Returning null here actually makes it easier to implement and interpret.
I will change it to return null for ServletContext#getResponseCharacterEncoding unless there is any objection.

Shing Wai Chan

>
> Generally, I am of the view that getters and setters should be symmetric
> unless there is a good reason not to be.
>
> I'd be happy with a default of ISO-8859-1 but if explicitly set to null
> then the getter should return null.
>
> Mark
>