I am re-posting the problem we are facing, as I did not get any reponse on this from
the group.
We are 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 that we are facing is - we are unable to display any
error messages on the Login screen (login.jsp), in case the user does
not enter any data in the Login ID and/or password fields and clicks
on the Submit button.
The validate() method has been activated. Part-code of this method in
the extended ActionForm is shown:
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;
We have tried displaying the error messages in login.jsp (part-code)
with (and with no success):
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<html:messages id="error" message="false">
<L1><bean:write name="error"/></L1>
</html:messages>
OR
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<logic:messagesPresent>
<UL>
<html:messages id="error" message="false">
<L1><bean:write name="error"/></L1>
</html:messages>
</UL>
</logic:messagesPresent>
Please note if we use: <html:errors />
in login.jsp then we are able to display the errors! We want to do the same without
<html:errors />
The web.xml located in the WEB-INF folder of our application does not
have any <taglib> tags (as required by version 1.2.4)
The struts-config.xml in the WEB-INF folder of our application has
the line:
<message-resources parameter="LoginMessageResources" null="false" />
The contents of LoginMessageResources.properties located in the WEB-
INF\classes folder of our application has:
# Errors
errors.loginID.required=LoginID cannot be blank
errors.password.required=Password cannot be blank
Could anyone point out the problem?
All help most appreciated.