Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1898162
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T06:43:57+00:00 2026-05-17T06:43:57+00:00

I am trying to implement internationalization in Tomcat. There are going to be different

  • 0

I am trying to implement internationalization in Tomcat. There are going to be different resource text files. My idea is to load all the resources in to the memory while tomcat loads.
Below is the sample code to load multiple resource in to the memory.

public class ResourceBundleLoader {


    private static ResourceBundle enResourceBundle;
    private static ResourceBundle frResourceBundle;

    public static void loadBundle(){
        Locale enLocale = new Locale("en", "US");
        enResourceBundle = ResourceBundle.getBundle("MessagesBundle",enLocale);
        enLocale = new Locale("fr", "FR");
        frResourceBundle = ResourceBundle.getBundle("MessagesBundle",enLocale);
    }

    public static ResourceBundle getEnResourceBundle(){
        return enResourceBundle;
    }

    public static ResourceBundle getFrResourceBundle(){
        return frResourceBundle;
    }
}

The method loadBundle is called once thru startup servlet. And getEnResourceBundle() and getFrResourceBundle() is called accordingly. Is this right way to implement/maintain internationalization in tomcat? or is there any better way?

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T06:43:57+00:00Added an answer on May 17, 2026 at 6:43 am

    You dont need to make this helper class, as per the java documentation the bundles are already cached for you in memory. This will just make your code more complicated to maintain. ie You would have to alter your code every time you add a new “bundle”.

    Just add code like this to your servlets and/or JSP’s:

    //request.getLocale() returns the web browsers locale
    bundle = ResourceBundle.getBundle("MessagesBundle",request.getLocale())
    

    Just make sure you have a default message bundle file with all your text. Then you can just add extra locales at will as things get translated.

    UTF-8 support

    I also strongly suggest you create a servlet filter that applies to all requests that ensures that UTF-8 is turned on for both the html that is output, and the parsing of the form responses that are posted back to your application:

    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement internationalization as seen in railscasts, and every time I
All I am currently trying implement something along the lines of dim l_stuff as
I'm trying to implement internationalization in JSF 2. I've tried many solutions, but I'm
I'm trying to implement internationalization on my project, but the pages only get translated
trying to implement a dialog-box style behaviour using a separate div section with all
am trying to implement fluent nhibernate in MVC project...there were no build errors... but
I am currently trying to implement internationalization in an application (Python 2.6) and have
I'm trying implement A* Start path finding in my games(which are written with JavaScript,
I am trying implement a most recent widget into my tumblr post. So far,
Trying to implement LoaderManager + CursorLoader. In onFinish method adapter should swap its cursor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.