users@glassfish.java.net

Re: Can't set charset to UTF-8

From: <Jan.Luehe_at_Sun.COM>
Date: Thu, 08 Nov 2007 11:33:25 -0800

Hi Gerald,

Gerald Holl wrote:

> Jan.Luehe_at_Sun.COM wrote:
>
>> Gerald,
>>
>> Gerald Holl wrote:
>>
>>> Hello,
>>>
>>> I'm having troubles setting the charset to UTF-8 on Glassfish:
>>> [#|2007-11-07T14:38:01.059+0100|WARNING|sun-appserver9.1|org.apache.coyote.tomcat5.CoyoteRequest|_ThreadID=18;_ThreadName=httpSSLWorkerThread-8080-1;_RequestID=aa139129-bed8-45a9-adb5-d099637fcdf8;|PWC4011:
>>> Unable to set request character encoding to ISO-8859-1 from context
>>> /myapp, because request parameters have already been read, or
>>> ServletRequest.getReader() has already been called|#]
>>>
>>> I'm confused why the server complains about the ISO-8859-1 character
>>> encoding.
>>
>>
>>
>> The container does not complain about the encoding itself, only about
>> the fact
>> that you are trying to set the encoding too late, when it is
>> impossible for the container
>> to honor it.
>>
>> See the javadocs of ServletRequest.setCharacterEncoding():
>>
>> This method must be called prior to reading request parameters
>> or reading input using getReader(). Otherwise, it has no effect.
>>
>> The container issues a warning to let you know that your call to
>> ServletRequest.setCharacterEncoding() has no effect, because one of
>> the above conditions is met.
>>
>> You should move your call to ServletRequest.setCharacterEncoding()
>> before you acquire an input reader from the request, and before
>> you read any request parameters.
>
>
> Hello Jan,
>
> Thanks for your response.
>
> I didn't implement a servlet my own, I just use JSF and JSP. So I
> don't call ServletRequest.setCharacterEncoding() at any time.


I think I remember an issue where JSF was calling
ServletRequest.setCharacterEncoding()
too late, which was causing the warning message to be logged.

Would it be possible for you to add a

  Thread.currentThread().dumpStack()

to the beginning of

  
glassfish/appserv-webtier/src/java/org/apache/coyote/tomcat5/CoyoteRequest.setCharacterEncoding()

and send the stacktrace, so we know who the caller is?

Thanks,


Jan