Multiple Locales, Multiple Applications, Single JBoss 4.5 instance

Posted on 2007-08-03
Last Modified: 2013-12-29

I am currently developing a set of applications that will all run in a single instance of a JBoss container (version 4.5). The applications have no shared code, but do have different Locales. Here are some (made-up) examples of what the applications / locales could be:


None of these applications are internationalized, and it is wort stressing that I am not enquiring about traditional internationalization (one app, many languages, locale determined by web browser OS settings at request time). Rather, this is a question of how to run multiple sites with different server locales on a single JBoss instance.

I have allready had a go at this, but I have not been succesfull in getting it to work. Here is the code that is not working:

In my servlet startup initialization:

<%@ page language="java" pageEncoding="UTF-8" session="true"%>
<%@ page import="java.util.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title> Internationalization Test </title>
        <h1>Country:  <%=Locale.getDefault().getCountry()%></h1>
        <h1>Language: <%=Locale.getDefault().getLanguage()%></h1>

I think this approach is flawed, as the last servlet to be initialized would set the same default locale for all applications running on the server.

Any ideas?


PS! your timezone selector for this form at ('') is impossible to use. I can't find London / GMT !
Question by:henrikpettersen
    LVL 9

    Expert Comment

    Get the locale of the request, not of your server
    LVL 9

    Expert Comment

    <%= request.getLocale().getCountry() %>

    Author Comment

    Thank you, Matthew, but this is not quite what I am attempting to achieve: If I get the locale from the request, I will get the location of the end user, i.e. if Windows country/language is set to spain/spanish, the web server will give me a spain/spanish locale (Please feel free to correct me if this assumption is incorrect).

    Perhaps I should try to rephrase the question a bit:
    How can I harcode the locale for a single application, instead of setting the locale at the server/global level?



    Author Comment

    ... By "if Windows country/language is set to spain/spanish", I mean the settings of the underlying ooperating system for the end user browsing the site.
    LVL 9

    Expert Comment

    Sorry I didn't understand the question. Now are you sure this is impacting the other applications ?
    Each application has it's own Java Virtual Machine I tought.
    LVL 9

    Accepted Solution

    Anyway you could define a new Locale in each application,
    and have a method getLocale in some class of the application which will give you the good locale instance.

    Author Comment

    Hm, yes. You're right. I'm overcomplicating things.

    Thank you!


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Suggested Solutions

    Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
    Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
    Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
    This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now