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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:02:51+00:00 2026-05-30T14:02:51+00:00

I’ve condensed the code to its barest essentials to illustrate my problem as clearly

  • 0

I’ve condensed the code to its barest essentials to illustrate my problem as clearly as I can.

I hope the formatting turns out ok – this is my first post with stackoverflow and no matter what I did, indent 4 spaces or use ctrl-K, the compiler was not happy.

My addAssignment.jsp is showing the header “Messages” when the LinkedList should be, and appears to be, empty. If there are no messages in the LinkedList, I expect the logic:present tag to preclude the printing of the header “Messages”. How do I prevent the header “Messages” from printing if there are no messages in the LinkedList?

<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  <title>Add Assignment Page</title>
  <style type="text/css">table { margin-left:5%; }</style>
</head>
<body>
  <table>
    <tr>
      <td>
        <logic:present name="messages">
          <h3>Messages:</h3>
          <logic:iterate id="msg" name="messages">
            <bean:write name="msg" /><br />
          </logic:iterate>
        </logic:present>
      </td>
    </tr>
  </table>
  <table>
    <tr>
      <td>
        <H1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Add Assignment</H1>
      </td>
    </tr>
  </table>
  <html:form action="addAssignmentAction" focus="injuredWorkersFirstName">
    <table>
      <tr>
        <td>First name</td>
        <td>&nbsp;&nbsp;&nbsp;
            <html:text property="injuredWorkersFirstName" />
        </td>
      </tr>
      <tr>
        <td class="100PixCentered">&nbsp;</td>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;<html:submit>submit</html:submit>
        </td>
      </tr>
    </table>
  </html:form>
</body>
</html>

The LoginAction file illustrates how I use the LinkedList. Also, the LoginAction works correctly with the Login.jsp page, the LinkedList and the Logic and Bean tags. That is, when error messages were present in the LinkedList, the Login.jsp page showed them corretly under the header Messages.

public class LoginAction extends Action {

    public void execute(Object data) { }

    public ActionForward execute(ActionMapping mapping, ActionForm form, 
             HttpServletRequest request, HttpServletResponse response) throws Exception {

        LinkedList messages = new LinkedList();
        String returnValue = "success";

        if ((((LoginForm) form).getName() == null) 
                || ((((LoginForm) form).getName()).length() == 0)) {
            messages.add("bad name");
            returnValue = "error";
        }

        if ((((LoginForm) form).getPassword() == null) 
                || ((((LoginForm) form).getPassword()).length() == 0)) {
            messages.add("bad password");
            returnValue = "error";
        }

        request.setAttribute("messages", messages);
        return mapping.findForward(returnValue);
    }
}

Struts configuration:

<struts-config>
  <data-sources></data-sources>
  <!-- ========== Form Bean Definitions =================================== -->
  <form-beans>
    <form-bean name="loginForm" type="package1.LoginForm" />
    <form-bean name="AddAssignmentForm" type="package1.AddAssignmentForm" />
  </form-beans>
  <!-- ========== Action Mapping Definitions ============================== -->
  <!-- Action Mappings Configuration -->
  <action-mappings>
    <action path="/login" type="package1.LoginAction" name="loginForm" 
        scope="request" validate="false" input="/index.jsp">
      <forward name="success" path="/addAssignment.jsp"></forward>
      <forward name="error" path="/index.jsp"></forward>
    </action>
    <action path="/addAssignmentAction" type="assignment.AddAssignmentAction" 
        name="AddAssignmentForm" scope="request" validate="false" 
        input="/addAssignment.jsp">
      <forward name="success" path="/mainMenu.jsp"></forward>
      <forward name="error" path="/addAssignment.jsp"></forward>
    </action>
  </action-mappings>
  <!-- ========== Message Resources Definitions =========================== -->
</struts-config>
  • 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-30T14:02:55+00:00Added an answer on May 30, 2026 at 2:02 pm

    Your expectations are wrong. As its name and documentation indicates, <logic:present> executes is body if the value is present in the request. Whether the attribute is an ampty list of not is irrelevant: the attribute is present, son the body is executed.

    You should use the <logic:notEmpty> tag instead or, even better, forget about these obsolete logic tags and use the JSTL <c:if> tag instead:

    <c:if test="${!empty messages}"> ... </c:if>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have this code to decode numeric html entities to the UTF8 equivalent character.
Does anyone know how can I replace this 2 symbol below from the string
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,

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.