<%@ page language="java" import="org.apache.struts.action.*" %> <%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> Test Error and Message Tags <% ActionErrors errors = new ActionErrors(); errors.add("property1", new ActionError("property1error1")); errors.add("property2", new ActionError("property2error1")); errors.add("property2", new ActionError("property2error2")); errors.add("property2", new ActionError("property2error3")); errors.add("property3", new ActionError("property3error1")); errors.add("property3", new ActionError("property3error2")); errors.add(ActionErrors.GLOBAL_ERROR, new ActionError("globalError")); request.setAttribute(Action.ERROR_KEY, errors); ActionMessages messages = new ActionMessages(); messages.add("property1", new ActionMessage("property1message1")); messages.add("property2", new ActionMessage("property2message1")); messages.add("property2", new ActionMessage("property2message2")); messages.add("property2", new ActionMessage("property2message3")); messages.add("property3", new ActionMessage("property3message1")); messages.add("property3", new ActionMessage("property3message2")); messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("globalMessage")); request.setAttribute(Action.MESSAGE_KEY, messages); %>

Test Error and Message Tags

ERRORS Tag

Test Type Correct Value Test Result
Errors for Property 1
Property 1, Error 1
Errors for Property 2
Property 2, Error 1
Property 2, Error 2
Property 2, Error 3
All Errors
Property 1, Error 1
Property 2, Error 1
Property 2, Error 2
Property 2, Error 3
Property 3, Error 1
Property 3, Error 2
Global Error

MESSAGES Tag

Test Type Correct Value Test Result
Messages for Property 1
Property 1, Message 1
<%= pageContext.getAttribute("msg") %>
Messages for Property 2
Property 2, Message 1
Property 2, Message 2
Property 2, Message 3
<%= pageContext.getAttribute("msg") %>
All Messages
Property 1, Message 1
Property 2, Message 1
Property 2, Message 2
Property 2, Message 3
Property 3, Message 1
Property 3, Message 2
Global Message
<%= pageContext.getAttribute("msg") %>