Here's a simple way to do it. Just put the following saveError() method into your controller:
Code:
public void saveError(HttpServletRequest request, String msg) {
List errors = (List) request.getAttribute("errors");
if (errors == null) {
errors = new ArrayList();
}
errors.add(msg);
request.setAttribute("errors", errors);
}
And then add something like the following to your JSP.
Code:
<c:if test="${not empty errors}">
<div class="error">
<c:forEach var="error" items="${errors}">
<img src="<c:url value="/images/iconWarning.gif"/>"
alt="<fmt:message key="icon.warning"/>" class="icon" />
<c:out value="${error}" escapeXml="false"/><br />
</c:forEach>
</div>
</c:if>