dev@glassfish.java.net

Re: error-page encoding problem

From: Jan Luehe <Jan.Luehe_at_Sun.COM>
Date: Mon, 10 Jul 2006 19:36:30 -0700

Hi Dmitry,

Jan Luehe wrote On 06/28/06 18:16,:

> Hi Dmitry,
>
> I'm looking into this issue and will get back to you.


I assume that the invocation of error.jsp is caused by another JSP
(which throws the Throwable), and that this JSP does not set the response
encoding to UTF-8 (either directly via the contentType page directive
attribute,
or indirectly via the pageEncoding page directive attribute)?

I further assume that in the case where error403.jsp or error404.jsp
is invoked (and the response encoding is correctly set to UTF-8), the
invocation of the error page is not caused by any JSP?

Notice that if you had a JSP that looked like this:

  <% response.sendError(404); %>

error404.jsp would be invoked, but the response contentType would be
just "text/html" (without any UTF-8 charset), causing ??? in the
response, just as in the case where error.jsp is invoked.

Bottom line is that at the end of a JSP page invocation, the contents
of the JSP page's buffer are flushed to the response writer (returned
by a call to ServletResponse.getWriter()), meaning that any subsequent
attempts to set the response charset (in your examples: to UTF-8) will fail.

Currently, ServletResponse.getWriter() is called even if the JSP
page's buffer is empty (notice that this buffer is cleared when the JSP
throws
an exception), preventing the error page from setting the
response charset. I am investigating if a call to
ServletResponse.getWriter()
could be avoided in this case.

In the meantime, I've filed
https://glassfish.dev.java.net/issues/show_bug.cgi?id=815
to track this issue.

Thanks,


Jan

>
> Thanks,
>
> Jan
>
>
> Dmitry Mozheyko wrote On 06/27/06 01:39,:
>
>> -----Original Message-----
>> From: "Ostap Cherkashin" <ostap.cherkashin_at_gmail.com>
>> To: dev_at_glassfish.dev.java.net
>> Date: Tue, 27 Jun 2006 11:15:23 +0400
>> Subject: Re: error-page encoding problem
>>
>>
>>
>>> Dear Dmitry,
>>>
>>> Please check that you have saved the mentioned JSPs in utf8 encoding.
>>>
>>
>>
>> Yes, all jsp pages are saved in UTF-8 encoding.
>>
>>
>>
>>> Regards,
>>> Ostap
>>>
>>> On 6/27/06, Dmitry Mozheyko <mozheyko_d_at_mail.ru> wrote:
>>>
>>>
>>>> Hi all!
>>>> I use GlassFish v2 (build b07) and i need to custom error page
>>>> web.xml:
>>>>
>>>> ...
>>>> <error-page>
>>>> <exception-type>java.lang.Throwable</exception-type>
>>>> <location>/error.jsp</location>
>>>> </error-page>
>>>> <error-page>
>>>> <error-code>403</error-code>
>>>> <location>/error403.jsp</location>
>>>> </error-page>
>>>> <error-page>
>>>> <error-code>404</error-code>
>>>> <location>/error404.jsp</location>
>>>> </error-page>
>>>> ...
>>>>
>>>>
>>>>
>>>> Both error403.jsp and error404.jsp pages correctly showing UTF-8
>>>> symbols, but error.jsp:
>>>>
>>>> <%_at_page contentType="text/html"%>
>>>> <%_at_page pageEncoding="UTF-8"%>
>>>> <jsp:include page="jspf/header.jsp" />
>>>> <b>Ошибка:</b><br />
>>>> <%=((Throwable)request.getAttribute("javax.servlet.error.exception")).toString()%><br
>>>> />
>>>> <button onclick="goback()">Назад</button>
>>>> <jsp:include page="jspf/footer.jsp" />
>>>>
>>>>
>>>>
>>>> Show '?' signes instead russian symbols.
>>>>
>>>> How to fix it?
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>>>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>>>
>>>>
>>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>>
>>
>