How can I use JSTL fmt:message with Struts custom MessageResources class?

Posted on 2006-05-11
Last Modified: 2013-11-24
I've seen lots of examples of using fmt:message when you have resource bundles.  However, I need to get my translated strings from a database so I had to create a custom class to extend MessageResources.  I've gotten bean:message to work just fine, but would like the extended functionality of fmt:message.  

Here's what in my web.xml:

Here's what's in my struts-config:

 <message-resources parameter="com.mycompany.MyMessageResources"
            factory="com.myCompany.MyMessageResourceFactory" key="branding"
            null="true" />

Here is what works:
<bean:message key="testMsg" bundle="branding" />

Here is what doesn't work:
<fmt:setBundle basename="com.mycompany.MyMessageResources"
    var="lang" scope="session"/>
<fmt:message key="testMsg" bundle="${lang}"/>

I don't get an error, but it can't seem to find the message either.  Please help!  I've been googling everywhere and can't find any examples of this.  I've tried various values for baseName and the param-value, but nothing seems to be working.

Question by:jmta
    1 Comment
    LVL 23

    Accepted Solution


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Suggested Solutions

    INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

    758 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