You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by maxt <ma...@yahoo.com.au> on 2006/11/04 01:43:07 UTC

Locale difference with Console and Windows Service

I am using Windows XP, Tomcat 5.5.17, JRE 1.5.0_08. I am in Australia. To
test localization, my Windows Region is set to English, US. 

When using the Console, tomcat5.exe, my localization files work correctly,
returning the Locale, en_US. 

When using Windows Services, the Locale returned is en.AU with the same code
and Region still set to English, US. 

In the Services I am using a Classpath command: C:\Program
Files\BMJ\Tomcat\bin\bootstrap.jar and Java Options: 
-Dcatalina.base=C:\Program Files\BMJ\Tomcat 
-Dcatalina.home=C:\Program Files\BMJ\Tomcat 

Any help explaining how to get the default Locale using Services would be
appreciated. I do not want to set the Locale, but to get and apply my users
default Locale using Services. 

The same problem applies to the use of the Robot class used for sending
keystrokes. OK with Console, no response or error with Services. 

Max

-- 
View this message in context: http://www.nabble.com/Locale-difference-with-Console-and-Windows-Service-tf2572041.html#a7170215
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Max,

maxt wrote:
> Is there anything about an install of JRE or Tomcat that is inherently
> Region based?

I don't believe so. Your JRE will have a default locale that it picks
based upon some voodoo with your operating system, etc. For instance,
I'm in the US, to it defaults to en_US. I would imagine that yours would
default to en_AU since you are (??) in Australia.

If you change your user prefs to another language or locale, I would
imagine that any new JVMs that you start up would use the new locale.

I would also imagine that if you ran Tomcat as a service, that the user
who runs the service has their own locale which is different from your
user's locale. That was probably set during OS installation, but is
probably changeable somehow.

> eg, Do I need to reinstall Tomcat or JRE when my region is US?

That doesn't seem likely.

> It was AU when installed. In other words, was the Region change
> totally effective when these apps were initially installed with a AU
> Region?

Run this code to see all of the JVM settings, including the locale:

public class Env
{
    public static void main(String[] args)
    {
        System.getProperties().list(System.out);
    }
}

Look at the "user.language" and "user.country" properties. Together, I
believe that these define the default locale for the VM. If you want to
load resource bundles with different locales, you'll need to detect the
locale however you want (including simply flat-out asking the user), and
then load the appropriate bundle.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFURZ19CaO5/Lv0PARAr1PAJ9CXn3PL9X5aQnYRD4OvgZrYReVjgCeKrzx
XF7+dthb6o9d+x4Nmlp34ow=
=qVPL
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by maxt <ma...@yahoo.com.au>.
Exactly. Strange one.

Is there anything about an install of JRE or Tomcat that is inherently
Region based?

eg, Do I need to reinstall Tomcat or JRE when my region is US? It was AU
when installed. In other words, was the Region change totally effective when
these apps were initially installed with a AU Region?

Max


Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Max,
> 
> maxt wrote:
>> To give a little more background, I have a Servlet, Tomcat application
>> that a
>> potential customer can download and install on their Windows PC. I would
>> like to create localizations for it.
>> 
>> It is easier to enable such a person to use Windows Services to start
>> Tomcat
>> without having any knowledge of Tomcat.
>> 
>> I have been testing this on my own Australian computer by changing the
>> Region to en_US.
>> 
>> The Robot enables the potential customer to follow a set of AccessKey
>> based
>> HTML pages to do an initial setup of their own situation.
> 
> Aah. That makes a lot more sense, now.
> 
>> These two functions do not seem to work correctly on my Australian
>> computer
>> when Region is en_US with Tomcat Services, but are OK when using the
>> Console.
> 
> So, it's not that your servlet is having problems, then. It's the
> installation that you are trying to script that's acting funny? Or both?
> 
> - -chris
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFFT87c9CaO5/Lv0PARAqclAKCnnV3bv1QjJ9mloWRinUwO8If9wQCfS2nk
> 9EaVDPeQexhNo0sY2tL9fX4=
> =jVsb
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Locale-difference-with-Console-and-Windows-Service-tf2572041.html#a7228995
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Max,

maxt wrote:
> To give a little more background, I have a Servlet, Tomcat application that a
> potential customer can download and install on their Windows PC. I would
> like to create localizations for it.
> 
> It is easier to enable such a person to use Windows Services to start Tomcat
> without having any knowledge of Tomcat.
> 
> I have been testing this on my own Australian computer by changing the
> Region to en_US.
> 
> The Robot enables the potential customer to follow a set of AccessKey based
> HTML pages to do an initial setup of their own situation.

Aah. That makes a lot more sense, now.

> These two functions do not seem to work correctly on my Australian computer
> when Region is en_US with Tomcat Services, but are OK when using the
> Console.

So, it's not that your servlet is having problems, then. It's the
installation that you are trying to script that's acting funny? Or both?

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFT87c9CaO5/Lv0PARAqclAKCnnV3bv1QjJ9mloWRinUwO8If9wQCfS2nk
9EaVDPeQexhNo0sY2tL9fX4=
=jVsb
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by maxt <ma...@yahoo.com.au>.
To give a little more background, I have a Servlet, Tomcat application that a
potential customer can download and install on their Windows PC. I would
like to create localizations for it.

It is easier to enable such a person to use Windows Services to start Tomcat
without having any knowledge of Tomcat.

I have been testing this on my own Australian computer by changing the
Region to en_US.

The Robot enables the potential customer to follow a set of AccessKey based
HTML pages to do an initial setup of their own situation.

These two functions do not seem to work correctly on my Australian computer
when Region is en_US with Tomcat Services, but are OK when using the
Console.

Max



Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Max,
> 
> maxt wrote:
>>> Is the locale of your /user/ set to en_US, or is the whole OS set to
>>> that?
>> 
>> The Windows OS is therefore set to US. When I refer to a user, I am not
>> referring to a Unix type user but a customer who may be in any Region or
>> Locale.
> 
> Sorry, my mistake.
> 
>>> Since windows services run as another user (I'm sure you can pick), you
>>> need to make sure that the locale of /that/ user is set appropriately.
>>> Is it possible that the user that services "run as" is not configured
>>> for en_US?
>> 
>> Why does a Service pick up another Locale to the use of a Console?
> 
> Well, when you run startup.sh from the command-line, Java picks /your/
> locale as the default (en_US). When the service runs, it picks the
> locale based upon the user used to run the service (which I assume is
> still set to en_AU). If that's not the case, then I don't understand it.
> 
>> Everything else is the same. Run as Console is OK, then run as a Servie
>> and it is picking up the original Region set on Java installation (that
>> has since been changed for testing) perhaps??
> 
> IIRC, Java installations themselves do not have a locale. It all depends
> on the user who actually started the VM.
> 
>>> In our apps, we sniff the locale of the user from the request and stick
>>> it in the session (actually, Struts does that for us). You can then use
>>> that locale for resource bundles, time and date formatting, etc. Any
>>> reason to worry about the "default" locale in your case?
>> 
>> The resource bundles work OK for Console, but not for Service.
> 
> How do you determine the locale of the remote (web) user? Are you
> storing that locale information anywhere?
> 
>>>>> The same problem applies to the use of the Robot class used for
>>>>> sending
>>>>> keystrokes. OK with Console, no response or error with Services. 
>>>
>>> Well, that's a different problem. Do services have a console to run in?
>>> I would imagine that the service gets run in a manner quite like a UNIX
>>> app with no X availability. If that's true, then there's nothing to
>>> which you can send keystrokes.
>> 
>> The keystrokes are being sent to HTML fields in a JSP page.
> 
> You have a servlet that sends keystrokes to an HTML field in a JSP page?
> I think I'm totally confused at this point. Aren't you /generating/ that
> page to display on the remote client? If so, why do you need to send
> keystrokes to anything? Or, is this some unit-testing rig that you are
> talking about?
> 
>> I am not using Struts.
> 
> I only mentioned struts because it does some of our dirty work for us.
> It doesn't matter if you do or do not use struts; the fact remains that
> you need to detect your /remote/ client's locale.
> 
> It sounds like you are changing your own user's locale (from en_AU to
> en_US) and then attempting to access your webapp through a browser. That
> should all work completely, regardless of how you start Tomcat (the
> remote client should always send their preferred locale in HTTP
> headers). I suspect that you are incorrectly determining the locale of
> the remote user, and instead getting the locale of the local (on the
> server) user.
> 
> - -chris
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFFTOH19CaO5/Lv0PARAv/ZAJwKJC4VFWUCu9ZT+Nbh5/WYxnvAWgCgjKoF
> RN4YoFvfGt/sRS7Z/uCKpk0=
> =krgB
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Locale-difference-with-Console-and-Windows-Service-tf2572041.html#a7209068
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Max,

maxt wrote:
>> Is the locale of your /user/ set to en_US, or is the whole OS set to that?
> 
> The Windows OS is therefore set to US. When I refer to a user, I am not
> referring to a Unix type user but a customer who may be in any Region or
> Locale.

Sorry, my mistake.

>> Since windows services run as another user (I'm sure you can pick), you
>> need to make sure that the locale of /that/ user is set appropriately.
>> Is it possible that the user that services "run as" is not configured
>> for en_US?
> 
> Why does a Service pick up another Locale to the use of a Console?

Well, when you run startup.sh from the command-line, Java picks /your/
locale as the default (en_US). When the service runs, it picks the
locale based upon the user used to run the service (which I assume is
still set to en_AU). If that's not the case, then I don't understand it.

> Everything else is the same. Run as Console is OK, then run as a Servie
> and it is picking up the original Region set on Java installation (that
> has since been changed for testing) perhaps??

IIRC, Java installations themselves do not have a locale. It all depends
on the user who actually started the VM.

>> In our apps, we sniff the locale of the user from the request and stick
>> it in the session (actually, Struts does that for us). You can then use
>> that locale for resource bundles, time and date formatting, etc. Any
>> reason to worry about the "default" locale in your case?
> 
> The resource bundles work OK for Console, but not for Service.

How do you determine the locale of the remote (web) user? Are you
storing that locale information anywhere?

>>>> The same problem applies to the use of the Robot class used for sending
>>>> keystrokes. OK with Console, no response or error with Services. 
>>
>> Well, that's a different problem. Do services have a console to run in?
>> I would imagine that the service gets run in a manner quite like a UNIX
>> app with no X availability. If that's true, then there's nothing to
>> which you can send keystrokes.
> 
> The keystrokes are being sent to HTML fields in a JSP page.

You have a servlet that sends keystrokes to an HTML field in a JSP page?
I think I'm totally confused at this point. Aren't you /generating/ that
page to display on the remote client? If so, why do you need to send
keystrokes to anything? Or, is this some unit-testing rig that you are
talking about?

> I am not using Struts.

I only mentioned struts because it does some of our dirty work for us.
It doesn't matter if you do or do not use struts; the fact remains that
you need to detect your /remote/ client's locale.

It sounds like you are changing your own user's locale (from en_AU to
en_US) and then attempting to access your webapp through a browser. That
should all work completely, regardless of how you start Tomcat (the
remote client should always send their preferred locale in HTTP
headers). I suspect that you are incorrectly determining the locale of
the remote user, and instead getting the locale of the local (on the
server) user.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFTOH19CaO5/Lv0PARAv/ZAJwKJC4VFWUCu9ZT+Nbh5/WYxnvAWgCgjKoF
RN4YoFvfGt/sRS7Z/uCKpk0=
=krgB
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by maxt <ma...@yahoo.com.au>.


Christopher Schultz-2 wrote:
> 
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> 
> Max,
> 
>> I am using Windows XP, Tomcat 5.5.17, JRE 1.5.0_08. I am in Australia. To
>> test localization, my Windows Region is set to English, US. 
> 
> Is the locale of your /user/ set to en_US, or is the whole OS set to that?
> 
> The Windows OS is therefore set to US. When I refer to a user, I am not
> referring to a Unix type user but a customer who may be in any Region or
> Locale.
> 
>> When using the Console, tomcat5.exe, my localization files work
>> correctly,
>> returning the Locale, en_US. 
>> 
>> When using Windows Services, the Locale returned is en.AU with the same
>> code
>> and Region still set to English, US. 
> 
> Since windows services run as another user (I'm sure you can pick), you
> need to make sure that the locale of /that/ user is set appropriately.
> Is it possible that the user that services "run as" is not configured
> for en_US?
> 
> Why does a Service pick up another Locale to the use of a Console?
> Everything else is the same. Run as Console is OK, then run as a Servie
> and it is picking up the original Region set on Java installation (that
> has since been changed for testing) perhaps??
> 
>> Any help explaining how to get the default Locale using Services would be
>> appreciated. I do not want to set the Locale, but to get and apply my
>> users
>> default Locale using Services. 
> 
> In our apps, we sniff the locale of the user from the request and stick
> it in the session (actually, Struts does that for us). You can then use
> that locale for resource bundles, time and date formatting, etc. Any
> reason to worry about the "default" locale in your case?
> 
> The resource bundles work OK for Console, but not for Service.
>> The same problem applies to the use of the Robot class used for sending
>> keystrokes. OK with Console, no response or error with Services. 
> 
> Well, that's a different problem. Do services have a console to run in?
> I would imagine that the service gets run in a manner quite like a UNIX
> app with no X availability. If that's true, then there's nothing to
> which you can send keystrokes.
> 
> The keystrokes are being sent to HTML fields in a JSP page.
> 
> I am not using Struts.
> 
> Max
> 
> - -chris
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.5 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
> 
> iD8DBQFFTJvj9CaO5/Lv0PARAqgLAJ9aRaywkobHMGvqQ2vAhqnSVT4P1ACgpJCl
> Dr36WjN6ehgKCzoGe1jhRAs=
> =V6iz
> -----END PGP SIGNATURE-----
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Locale-difference-with-Console-and-Windows-Service-tf2572041.html#a7177248
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: Locale difference with Console and Windows Service

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Max,

> I am using Windows XP, Tomcat 5.5.17, JRE 1.5.0_08. I am in Australia. To
> test localization, my Windows Region is set to English, US. 

Is the locale of your /user/ set to en_US, or is the whole OS set to that?

> When using the Console, tomcat5.exe, my localization files work correctly,
> returning the Locale, en_US. 
> 
> When using Windows Services, the Locale returned is en.AU with the same code
> and Region still set to English, US. 

Since windows services run as another user (I'm sure you can pick), you
need to make sure that the locale of /that/ user is set appropriately.
Is it possible that the user that services "run as" is not configured
for en_US?

> Any help explaining how to get the default Locale using Services would be
> appreciated. I do not want to set the Locale, but to get and apply my users
> default Locale using Services. 

In our apps, we sniff the locale of the user from the request and stick
it in the session (actually, Struts does that for us). You can then use
that locale for resource bundles, time and date formatting, etc. Any
reason to worry about the "default" locale in your case?

> The same problem applies to the use of the Robot class used for sending
> keystrokes. OK with Console, no response or error with Services. 

Well, that's a different problem. Do services have a console to run in?
I would imagine that the service gets run in a manner quite like a UNIX
app with no X availability. If that's true, then there's nothing to
which you can send keystrokes.

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFTJvj9CaO5/Lv0PARAqgLAJ9aRaywkobHMGvqQ2vAhqnSVT4P1ACgpJCl
Dr36WjN6ehgKCzoGe1jhRAs=
=V6iz
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org