lets take an example of login error.
In your action class
ActionMessages messages = new ActionMessages();
if(invalid userid/pwd combination){
messages.add("logininvalid", new ActionMessage("invalid.user"));
saveMessages(request,messages);
return forward = mapping.findForward("error");
}
if(usernamenotpresent){
messages.add("missingusername", new ActionMessage("username.missing"));
saveMessages(request,messages);
return forward = mapping.findForward("error");
}
In your Applicationresources.properties file add this line
invalid.user=Invalid Username/Password combination
username.missing=Username is required
In your JSP
In this case the message is going to be displayed if present
<html:messages id="msg1" message="true" property="logininvalid">
<bean:write name="msg1"/><br>
</html:messages>
In this case you are not displaying the error message yet. just defining a bean to store the error message if present
<html:messages id="msg0" message="true" property="missingusername">
<bean:write name="msg0"/><br>
<bean
efine id="usernameerror" name="msg0" />
</html:messages>
<logic
resent name="usernameerror">
<font color="red">User Name:</font>
</logic
resent>
<logic:notPresent name="usernameerror">
User Name:
</logic:notPresent>