Hello all, I have a little problem with displaying an "Invalid login" message on my login page. I am using tomcat 5.0.28 and struts 1.2.4
I have a login.jsp that looks like this: <html:form action="login"> <!-- table stuff mostly snipped --> <td><bean:message key="logon.title"/></td> <td><bean:message key="logon.username"/></td> <td><html:text property="userName" value="" /></td> <td><bean:message key="logon.password"/></td> <td><html:password property="password" value="" /></td> <div align="right"><html:submit property="submit"> <bean:message key="logon.button.label"/> </html:submit> </html:form> <html:errors/> In my ActionForm, the validate method looks like this: public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (userName == null || userName.length() == 0) { errors.add("username", new ActionMessage("errors.username.required")); } if (password == null || password.length() == 0) { errors.add("password", new ActionMessage("errors.password.required")); } return errors; } When I leave username or password fields empty, I get the proper error messages as I expect, however, in my Action class "LoginAction" I have the following code to handel illegal logins: if (user != null) { fwd = mapping.findForward(SUCCESS); session.setAttribute("userName", userName); session.setAttribute("user", user); } else { ActionMessages errors = new ActionMessages(); errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.invalidlogin")); saveMessages(request, errors); fwd = mapping.findForward(ERROR); log.info(userName + " tried to login with invalid credentials."); } I have the "errors.invalidlogin" in application.properties file: errors.invalidlogin=Invalid username and password combination. (Other messages in that file are displayed properly, so the file is read and found by struts and the servlet container.) My struts-config.xml has these relevant tags: <form-beans> <form-bean name="LoginForm" type="my.package.LoginForm" /> <!-- others snipped --> </form-beans> <action path="/login" type="my.package.LoginAction" name="LoginForm" scope="session" input="/login.jsp"> <forward name="success" path="/Welcome.do" redirect="true" /> <forward name="error" path="/login.jsp" redirect="true" /> </action> Does anybody have a clue as to what I am doing wrong? As far as I can see, I'm doing everything the way it is described in the jakarta o'reilly book (Cavaness). Thank you all very much in advance for any input, Ian. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]