You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Satish Talim <sa...@hotmail.com> on 2004/10/08 09:20:59 UTC

Unable to display Errors

Hello all,

I am new to Struts and experimenting with a simple Login screen using Struts 1.2.4 with JBoss 4.0 and J2SDK 1.4.2.

The problem I am facing is that I am unable to display any error messages on my Login screen (login.jsp), in case the user does not enter any data on the Login ID and/or password fields and clicks on the Submit button.

In the validate() method of my Action Form (part-code), I have the code -
ActionErrors errors = new ActionErrors();

    ActionMessage msg = null;

    if (getLoginID() == null || getLoginID().length() < 1)
    {
      msg = new ActionMessage("errors.loginID.required");
      errors.add(ActionMessages.GLOBAL_MESSAGE, msg);
    }
    if (getPassword() == null || getPassword().length() < 1)
    {
      msg = new ActionMessage("errors.password.required");
      errors.add(ActionMessages.GLOBAL_MESSAGE, msg);
    }
    return errors;
    
I try to display the error messages in login.jsp (part-code) as:

<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
      <html:messages id="msg" message="true"> 
        <bean:write name="msg" /> 
      </html:messages> 

My web.xml located in the WEB-INF folder of my application does not have any <taglib> tags.

The struts-config.xml in the WEB-INF folder of my application has the line:
<message-resources parameter="LoginMessageResources.properties" null="false" />

The contents of LoginMessageResources.properties located in the WEB-INF\classes folder of my application has:
# Errors
errors.loginID.required=LoginID cannot be blank
errors.password.required=Password cannot be blank

Could anyone point out the problem? Thanks in advance.

Satish