Loading Java resource bundles with HTTP

Source: Internet
Author: User
Tags resource zip apache tomcat java se

Another way to use a resource bundle

Imagine this: You must provide a display widget that extracts the message keys (keys) and message substitution parameters from the database, finds the keys in the Java resource bundle, and then formats the messages and displays them. The only problem is that the resource bundle is in the Web application, not where your widget is located. In fact, Web applications are located on different servers.

This is not a typical use of Java resource bundles, but it could be a nightmare. How do you achieve this? In order not to have a vague explanation, this article includes a sample application for you to download and run. It will make it easier for you to demonstrate and help you do this.

Sample application and resource files

Examples of this case are provided for Ibm®websphere®application Server V7 and Apache Tomcat 6 running Java Platform Standard Edition (Java SE) 6. Java SE 6 is needed because the sample uses Java class Java.util.ResourceBundle.Control to implement a resource bundle load through HTTP, which is not available until Java se 6.

Installing the sample Application

The download sample materials included in this article include:

Sj_tomcat.zip contains:

Remoteresourcebundle.war

Autoparts.war

Autosales.war

Sj_was.zip contains:

Remoteresourcebundleear.ear

Autopartsear.ear

Autosalesear.ear

Sj_source.zip contains Java resources and other files that make up the sample. The resources used in Remoteresourcebundle.war include:

Src/remote/bundle/example/remoteresourcebundleloader.java

Src/remote/bundle/example/productcontextroots.java

Src/remote/bundle/example/messagesbundle.java

Src/remote/bundle/example/messagesbean.java

Src/remote/bundle/example/productcontextroots.properties

webcontent/remotebundledisplay.jsp

The resources used in Autoparts.war include: webcontent/remote/bundle/example/autoparts.properties

The resources used in Autosales.war include: webcontent/remote/bundle/example/autosales.properties

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.