In my Java application, I set the default system locale (Locale.getDefault()
) as Accept-Language header for the HTTP request to my tomcat web application.
In my case, this is de_DE
.
On server side, I try to get the locale by using request.getLocale()
. But I only get an empty string.
If I set the Accept-Language to de
, everything works fine.
Why does de_DE
not work as Accept-Language header?
EDIT:
This is my client side code:
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
connection.setRequestProperty("Accept-Language", Locale.getDefault().toString());
And this my server side code:
request.getLocale().toString(); //empty string
request.getHeader("Accept-Language"); //"de_DE"