struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Parnell, Giles (AU - Sydney)" <>
Subject ActionErrors getting lost between action and JSP
Date Thu, 16 Jan 2003 00:57:40 GMT
Hi there guys 

Wonder if you can help. I am trying to get the struts actionErrors to appear
on my error page. 
I can get them working when I use the html:errors tag and specify the exact
error I'm after, however I am now trying to output ALL the errors... with
zero luck so far.

I have added two errors to the actionErrors object in my action like so: 

if (true) 
                        log.error("MAJOR DEBUGGING !!!"); 
                        new ActionError 
                        ("errors.updatingError", "fingers", "CareerPlan")); 
                        new ActionError 
                        ("errors.XMLHydration" ));  
                        //request.setAttribute("errors", errors); 
                        VOErrors errors = new VOErrors(actionErrors); 
                        log.debug("Wot is the size of the actionErrors: " +
                        // XXX this always comes back as 2 
                        // Try just place a string array on request

                        String a = "this is my first error"; 
                        String b = "this is my second error"; 
                        String c = "this is my third error"; 
                        request.setAttribute("errors", errors); 
                        //XXX this didn't work either XXX 
                        return (mapping.findForward("failure"));        

The options i've tryed so far are:
   a)creating actionErrors, adding it to the request, and then forwarding to
my error page 
    b)creating a VOErrors, adding the actionErrors to the VO and forwarding
this VO to my error page 
     c)creating an arrayList of strings called errors, and forwarding to my
error page 

When tracing through my action, on leaving the action I can see that there
are two errors in the actionErrors object. However on hitting the jsp page,
and tracing through the html:errors tag - the errors object is always empty.

Heres my jsp: 
<%@ page language="java" import="org.apache.struts.action.ActionErrors,
java.lang.*, java.util.*," %>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %> 
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %> 

        response.setHeader("Cache-Control", "no-cache"); 
        response.setHeader("Pragma", "no-cache"); 
        response.setDateHeader("Expires", 0); 

                <title>oops in gEm!</title> 
                <script language="JavaScript"
                <link rel="stylesheet" href="../../static/css/default.css"

        <body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0"
marginwidth="0" marginheight="0"> 
	 <!XXXX DO i even need a form been? ... or can i just place the
actionErrors in the request and then use the html:errors tag ???>
        <html:form name="errors" scope="request"
                <!-- Top error banner - got the link back to the homepage
                <jsp:include page="includes/99_errors_nav_top.jsp"/>

                        <table class="table" border="0" cellspacing="0"
cellpadding="0" align="center"> 
                                        <td bgcolor="fed267" class="normal">
The following error(s) have occured - please fix or contact the system
administrator for help. </td>

                                        <td bgcolor="fed267" class="error"> 
                                        <!-- XXX debuggin --> 
                                                <% if
(request.getAttribute("errors") != null) 
e = (ActionErrors) request.getAttribute("errors");

                                                                if (e !=
size = e.size(); 
this always comes back as 0 XXX --> 
                                                                 ErrorSize =
                                                        { %> 
                                                                Errors is
                                                <% } %> 

                                                <!-- Think this is all i
need --> 

name="errors" property=""/></td -->


Is there something i'm missing here? Why does the errors attribute (whether
it's an array of strings, an actionError object) always seem to lose it's
value on hitting the jsp page.

Any help would be great. Cheers 

***********Confidentiality/Limited Liability Statement***************

Have the latest business news and in depth analysis delivered to your 
desktop. Subscribe to "Insights", Deloitte's fortnightly email 
business bulletin . . .

This message contains privileged and confidential information intended
only for the use of the addressee named above.  If you are not the 
intended recipient of this message, you must not disseminate, copy or 
take any action in reliance on it.  If you have received this message 
in error, please notify Deloitte Touche Tohmatsu immediately.  Any 
views expressed in this message are those of the individual sender, 
except where the sender specifically states them to be the views of 

The liability of Deloitte Touche Tohmatsu, is limited by, and to the 
extent of, the Accountants' Scheme under the Professional Standards 
Act 1994 (NSW).

The sender cannot guarantee that this email or any attachment to it 
is free of computer viruses or other conditions which may damage or
interfere with data, hardware or software with which it might be used.
It is sent on the strict condition that the user carries out and relies
on its own procedures for ensuring that its use will not interfere with
the recipients systems and the recipient assumes all risk of use and
absolves the sender of all responsibility for any consequence of its use.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message