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 665043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:40:00+00:00 2026-05-13T23:40:00+00:00

I am displaying ActionMessage s through a JSP file by the following command: <logic:messagesPresent

  • 0

I am displaying ActionMessages through a JSP file by the following command:

<logic:messagesPresent message="true">
    <ul id="messsages">
        <html:messages id="msg" message="true">
            <li><bean:write name="msg"/> </li>
        </html:messages>
    </ul>
</logic:messagesPresent>

Now I want to display only selected messages. How can I indicate which message to display?

Updated

Actually I have two ActionMessages object – messages and warnings.
Now I want to display both of them on separate JSP page… One page to show messages and other for warnings.

So how to indicate in the JSP page that which messages to display?

Updated – 2

Now, I found a strange thing.

saveMessages(request, messages);
saveMessages(request, warnings);

When I wrote the above code, only warnings was working. When I reversed the order of the above two statements, then only messages was working.

It seems that we can add only one ActionMessages object in a request. If it is correct, then how to display messages in two ActionMessages objects seperately.

  • 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-13T23:40:00+00:00Added an answer on May 13, 2026 at 11:40 pm

    Simple,

    Separate your messages and your warnings: In your struts action, save your messages and warnings as follows:

    //For messages
    saveMessages(request, messages);
    
    //For warnings
    saveErrors(request, warnings);
    

    To display them:

    <logic:messagesPresent message="true">
        <html:messages id="aMsg" message="true">
            <logic:present name="aMsg">
                <!-- Messages -->
                <div class="messages">
                    <bean:write name="aMsg" filter="false" />
                </div>
            </logic:present>
        </html:messages>
    </logic:messagesPresent>
    
    <logic:messagesPresent message="false">
        <html:messages id="aMsg" message="false">
            <logic:present name="aMsg">
                <!-- Warnings-->
                <div class="warnings">
                    <bean:write name="aMsg" filter="false" />
                </div>
            </logic:present>
        </html:messages>
    </logic:messagesPresent>
    

    This displays all messages (by setting message="true")

    <html:messages id="aMsg" message="true">
    

    This displays all warnings (by setting message="false")

    <html:messages id="aMsg" message="false">
    

    UPDATE Seeing that you’re now clearing your question, the simplest way would be to do this.

    Have a certain flag that will indicate whether the user would like to view messages or warnings. On the Struts Action, request the flag and check if the user selected viewing messages or warnings.
    You then save either warnings or messages based on the user selection and display the same page (as you wrote above) to display messages.

    The reason is this, Struts (when storing you messages or errors) stores it on request or session with the following constant.

    • Globals.MESSAGE_KEY (that is assigned when you do saveMessages(request, messages))
    • Globals.ERROR_KEY (that is assigned when you do saveErrors(request, errors))

    when using <logic:messagesPresent message="true">, Struts searches for the MESSAGE_KEY (if message=true) or ERROR_KEY (if message=false) or both (if message=none). You have no control of that.

    <html:messages /> TLD comments states:

    By default the tag will retrieve the
    bean it will iterate over from the
    Globals.ERROR_KEY constant string,
    but if this attribute is set to ‘true’
    the bean will be retrieved from the
    Globals.MESSAGE_KEY constant string.
    Also if this is set to ‘true’, any
    value assigned to the name attribute
    will be ignored.

    You can also write scriptlet to check if those keys exists, then <logic:iterate /> through the key to display the messages (but that’ll be too much work).

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.