I’m having some trouble with setting the Java locale in a JSP application, and I’m hopefully I’ll be able to find some answers on the board.
My company inherited an online web store written in JSP that has only previously been used in the US and the UK. We’ve now won a contract to set up a store for a UK company that also needs a German store, so we need to localize all of the text to be displayed in German. The existing code is fairly well written, but there was no concept of localization, and I’m not very familiar with it myself. So, I’ve ripped out the hard coded text from the HTML and replaced it with JSP tags and created the Resource bundles with appropriate text for en_US. I’ve also created a “test” Resource bundle for the German de_DE locale.
But now I’m having problems with setting the locale. The entry page to the store is a “Select Country” page and on that page I’m using the Java method “java.util.Locale.setDefault()” to set the locale. Now, from testing and my online research, it seems like that method changes the locale for the whole instance of the JVM (all users using the same webserver). This seems to me that is will effect other users on the webstore.
So, does that mean that I can’t run 1 webserver (or cluster) and when a user enters the store I set the default locale? Because if a person from the UK enters the store the default locale is set to en_UK, but if a German enters right afterwards, the default locale will be set to de_DE. Will the UK user pick up the German localizations?
Is there a way to set the localization for a particular JSP user session? Or do I have to have a different JVM for each language I need to support?
Thanks for the help.