You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by bu...@apache.org on 2013/08/10 19:50:55 UTC

[Bug 55399] New: Request English but Response Spanish Language (Default Locale)

https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

            Bug ID: 55399
           Summary: Request English but Response Spanish Language (Default
                    Locale)
           Product: Tomcat 7
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
          Assignee: dev@tomcat.apache.org
          Reporter: guillermo.grandes@gmail.com

== Server: Windows, Language: es_ES
== Client: Linux, Language: en_US

== Request:

POST /xxxxxx HTTP/1.1
Host: x.x.x.x:8080
Accept: */*
Accept-Language: en
Content-Length: 0
Content-Type: application/x-www-form-urlencoded

== Response:

HTTP/1.1 400 Petición incorrecta
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1030
Date: Sat, 10 Aug 2013 17:25:17 GMT
Connection: close

...cut...

---

HTTP Response "Petición incorrecta" must be in English. Right?

I tried to do response.setLocale() workarround in the Servlet but neither
works:

---
protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
// ...
    response.setLocale(Locale.ENGLISH); // Locale.US neither
// ...
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "BAD REQUEST");
}
---

HttpServletResponse.setLocale() don't honors?

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

--- Comment #6 from Mark Thomas <ma...@apache.org> ---
The error pages were simple to fix but fixing the HTTP response status line is
going to be more invasive. That part may end up being Tomcat 8 only because of
the internal changes required.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

--- Comment #3 from Christopher Schultz <ch...@christopherschultz.net> ---
That's certainly odd. How about this:

    System.out.println("current stack:");
        new Throwable("Stack Trace").printStackTrace();

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

Christopher Schultz <ch...@christopherschultz.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #1 from Christopher Schultz <ch...@christopherschultz.net> ---
What version of Tomcat?

Can you echo these items back to the client and post the output:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
//  ...
    ServletWriter out = response.getWriter();
    out.println("request locale=" + request.getLocale());
    out.println("server locale=" + Locale.getDefault());
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "BAD REQUEST");
}

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #7 from Mark Thomas <ma...@apache.org> ---
This has been fixed in trunk and 7.0.x and will be included in 7.0.43 onwards.

Error pages now use the Accept-Language header.

All responses use the Locale set on the response.

I considered parsing the Accept-Language header on every request and using that
to set the locale on every response but decided not to on performance grounds
(no hard numbers on this so if someone shows the performance impact is
negligible then it could get added). Users that want this can easily write a
filter to do so.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

--- Comment #8 from Guillermo Grandes <gu...@gmail.com> ---
(In reply to Mark Thomas from comment #6)
> The error pages were simple to fix but fixing the HTTP response status line
> is going to be more invasive. That part may end up being Tomcat 8 only
> because of the internal changes required.

In that case, perhaps the logical would respond in English (ubiquitous) by
default, and set locale when requested... right?

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

--- Comment #2 from Guillermo Grandes <gu...@gmail.com> ---
Tested on tomcat-7.0.42

ServletWriter.println() don't work as expect (response.sendError clear the
response buffer), but changing ServletWriter to System.out output is:

protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    // ...
    System.out.println("request locale=" + request.getLocale());
    System.out.println("server locale=" + Locale.getDefault());
    response.sendError(HttpServletResponse.SC_BAD_REQUEST, "BAD REQUEST");
}

--- Eclipse console ---
request locale=en
server locale=es_ES
---

# Request:
curl -i -H "Accept-Language: en" -d "" "http://x.x.x.x:8080/LocaleTest"
---
HTTP/1.1 400 Petición incorrecta
Server: Apache-Coyote/1.1
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 1010
Date: Sun, 11 Aug 2013 21:29:02 GMT
Connection: close

<html><head><title>Apache Tomcat/7.0.42 - Informe de Error</title><style><!--H1
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}
H2
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}
H3
{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}
BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}
B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P
{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A
{color : black;}A.name {color : black;}HR {color : #525D76;}--></style>
</head><body><h1>Estado HTTP 400 - BAD REQUEST</h1><HR size="1"
noshade="noshade"><p><b>type</b> Informe de estado</p><p><b>mensaje</b> <u>BAD
REQUEST</u></p><p><b>descripción</b> <u>El requerimiento enviado por el cliente
era sintácticamente incorrecto.</u></p><HR size="1"
noshade="noshade"><h3>Apache Tomcat/7.0.42</h3></body></html>
---

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

Konstantin Kolinko <kn...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |steve@rkbb.co.uk

--- Comment #9 from Konstantin Kolinko <kn...@gmail.com> ---
*** Bug 56374 has been marked as a duplicate of this bug. ***

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

--- Comment #4 from Guillermo Grandes <gu...@gmail.com> ---
java.lang.Throwable: Stack Trace
    at org.test.servlet.LocaleTest.doPost(LocaleTest.java:138)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
    at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
    at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
    at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
    at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
    at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
    at
org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
    at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
    at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
    at
org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
    at
org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
    at
org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1686)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:662)

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


[Bug 55399] Request English but Response Spanish Language (Default Locale)

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55399

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #5 from Mark Thomas <ma...@apache.org> ---
This report doesn't surprise me at all.

The manager application had a similar issue.

I'll look at using a similar approach as used for the manager application for
the error pages.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org