You should see something - probably an error - have you checked the
logs? Also have you configured your message resources in the
struts-config.xml?

<message-resource parameter="myPackage.ApplicationResources" null="false" />

Also, you're "resolving the message" in your action - theres no need
to do that, thats what the <htmll:errors> tag does (and
<html:messages>), so you should have something like the following:

   if (request.getParameter("portal") == null) {
       ActionErrors errors = new ActionErrors();
       errors.add("portal", new ActionMessage("errors.portal.not.supplied"));
       saveErrors(request, errors);
       return mapping.findForward("error");
   }

More info here:

http://www.niallp.pwp.blueyonder.co.uk/HelpTagsErrorsAndMessages.html

Niall

On 10/18/06, Perry Minchew <[EMAIL PROTECTED]> wrote:
Hi all.

Struts newb reporting. I have been working on a new web app for our company
to streamline registration, and am still stumbling through the basic
building blocks of struts. I am using Struts 1.3.5 on Tomcat v5.5. I am
trying to add error handling into my process now.

The current problem is, I cannot use the ActionErrors functionality to
display errors on the jsp page.

Here's what I have:

Struts-config.xml:
            <global-forwards>
                        <forward name="error" path="/error.jsp"/>
            </global-forwards>

            <action-mappings>
                        <action path="/Register2"
type="mil.navy.spawar.registration.action.RegisterAction">
                                    <forward name="register2"
path="/register2.jsp" />
                                    <forward name="existingUser"
path="/existingUser.jsp" />

                        </action>

            </action-mappings>


RegisterAction.java:

public class RegisterAction extends Action {

            public ActionForward execute(
                                    ActionMapping mapping,
                                    ActionForm form,
                                    HttpServletRequest request,
                                    HttpServletResponse response) throws
Exception {

                        ....

                        if(request.getParameter("portal") == null) {

                                    MessageResources messageResources =
getResources(request);

                                    ActionErrors errors = new
ActionErrors();

                                    errors.add("portalNotFound", new
ActionMessage(messageResources.getMessage("errors.portal.not.supplied")));

                                    saveErrors(request, errors);

                                    return mapping.findForward("error");

                        }

                        .....

                        return mapping.findForward("register2");

error.jsp:

<body>

<logic:messagesPresent>

            <html:errors/>

</logic:messagesPresent>

</body>



I've even tried

<body>
            <html:errors/>
</body>


and in my messageResources properties:

errors.portal.not.supplied=You must access the registration page supplying a
portal parameter.


I get redirected to the errors page correctly if I neglect to put the portal
parameter on the action call, but the ActionError does not display on the
screen. Does anyone have any idea why this is failing to display the errors?


Thanks much,

Perry Minchew

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to