Thank you for your advices! That helped improving my understanding of struts alot! At first glance I like the aproach with "validate=false" and calling the validate method myself in the LoginAction class, so I have the control when to validate.
Regards, Chris > I generally like to stay away from using login.jsp AND a failure.jsp. > Mainly > because its two different pages to maintain, when they look very similar. > > So use just login.jsp for both just simple login, and failure. > > I would suggest that in your DisplayLoginAction or similar, set a request > attribute like isDisplayLogin that tells you that it is not a failure. If > after validation failture you are being forwarded to login.jsp , > isDisplayLogin will not be set. Now you can render the jsp with your > failure > stuff. > > I am not a Struts expert, but my feeling is that you SHOULD be checking if > user has entered login and password, but you SHOULD NOT be checking if > that > combination is right in the FormBean. That SHOULD be done in the Action, > so > you can decide what to do next.. > > My authentication filter is not implemented using struts, so I don't use > the > above scenario myself, yet. > > My 2 cents.. > > Pritpal Dhaliwal > > > -----Original Message----- > From: Richard Hightower [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 13, 2004 9:20 AM > To: Struts Users Mailing List; [EMAIL PROTECTED] > Subject: RE: ActionForm - redirect to custom JSP after validation failed > > > First, the behavior experiencing is as designed. I suggest getting a good > book on Struts geared for Struts novices like Professional Struts > published > by Wrox (written by James Goodwill and me). > > You can turn validation off in the action mapping (action element in the > struts config file) by setting the validate attribute to false (the > default > is true). > > That said.... > > Here is what I would do (and have done in a similar situation). > > Turn validation off by setting validate=false on the action mapping: > > <action path="/foo" name="loginForm" validate="false" > type="buy.my.book.FooAction"> > > <forward name="failure" ... > </action> > > > Have the action's execute method calll the validation method of the > ActionForm, then forward to anywhere you would like. > > ActionErrors errors = form.validate(); > > //if errors not empty forward to failure > return mapping.findForward("failure"); > > > Rick Hightower > Developer > > Struts/J2EE training -- http://www.arc-mind.com/strutsCourse.htm > > Struts/J2EE consulting -- > http://www.arc-mind.com/consulting.htm#StrutsMentoring > > -----Original Message----- > From: Christian Schlaefcke [mailto:[EMAIL PROTECTED] > Sent: Tuesday, January 13, 2004 9:27 AM > To: [EMAIL PROTECTED] > Subject: ActionForm - redirect to custom JSP after validation failed > > > Hi Folks, > > I have a simple login.jsp that I want to validate. So I have a Class > "LoginForm" with a "validate" method, that fills up the ActionErrors with > the errors that might occur (missing username/password, wrong > username/password). Later the execute method of the corresponding Action > class "LoginAction" checks those ActionErrors. If not empty I try to > return > a forward to "failure.jsp". > > The problem I have is that before my LoginAction could execute my custom > forward the RequestProcessor of Struts tells in the logs, that validation > has failed and request will be forwarded to /login.jsp (which is of course > the input item of this action in struts-config.xml). When a validation > error > occurs my LoginAction class is never called. > > I searched the archive of this list already but couldnīt get through the > solutions I found there. I still donīt understand why this is happening > and > what I can do to redirect to a custom failure.jsp. > > Could someone please explain in newbie-style ;-) ? > > Thanks & Regards! > > Chris > > --------------------------------------------------------------------- > 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] > > > > --------------------------------------------------------------------- > 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]