Asad Habib wrote:
Has anyone successfully used declarative exception handling with Struts? For some reason, my application always forwards to the input attribute of the action element instead of the path element of the exception element as defined in my struts configuration file. I have confirmed that the error is being generated by the validateRequired method of the Struts Validator by using <html:errors> to flush the errors on the page that I am forwarded to (login.jsp in this case). However, I am never forwarded to 'loginError.jsp'. Below is my 'struts-config.xml'. Any help would be appreciated. Thanks.

I think what's happening here is that the Exception is being thrown before the action is executed, i.e., during the validateRequired method of DynaValidatorForm as you say.

Think the exception element that you've indicated applies only to exceptions thrown from Action.execute. The validateRequired method occurs earlier in the request processing than does Action.execute. If your curious, you can look at ActionServlet and RequestProcessor source for more info.


-Dave


- Asad


<struts-config>
   <form-beans>
<form-bean name="loginForm" type="org.apache.struts.validator.DynaValidatorForm">
          <form-property name="userName" type="java.lang.String" />
          <form-property name="userPassword" type="java.lang.String" />
      </form-bean>
   </form-beans>

   <action-mappings>
<action path="/login" type="actions.LoginAction" name="loginForm" input="/login.jsp" validate="true"> <exception key="error.login.required" path="/loginError.jsp" type="org.apache.struts.util.ModuleException" />
      </action>
   </action-mappings>

   <message-resources parameter="MyResources" null="false" />

   <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property property="pathnames" value="/WEB-INF/validator-rules.xml, /WEB-INF/validator.xml" />
   </plug-in>
</struts-config>

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



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

Reply via email to