I didn't see any error in you code. I ran in my machine it works fine.
You can test just a Login action and debug from there.
On 4/14/2012 2:37 PM, Oussama Jlassi wrote:
i use struts 1.3 in tomcat 6 every thing work fine but the html error do not display my error messages how to fix it
login.jsp
<%@ page language="java" pageEncoding="ISO-8859-1"%><%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %><%@
taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %><%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <div style="color:red">
<html:errors/> </div> <html:form action="/Login"> User Name :<html:text name="loginf" property="userName"/> <br> Password :<html:password name="loginf"
property="password"/> <br> <html:submit value="login"/> </html:form>
</body></html:html>
LoginForm.java
import javax.servlet.http.HttpServletRequest;import
org.apache.struts.action.ActionErrors;import
org.apache.struts.action.ActionMapping;import
org.apache.struts.action.ActionMessage;import
org.apache.struts.action.ActionForm;
public class LoginForm extends ActionForm { private String userName;
private String password; public LoginForm() { }
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { ActionErrors errors = new
ActionErrors(); if (userName == null || userName.length()< 1) { errors.add("userName", new
ActionMessage("error.userName.required")); } if (password == null || password.length()< 1) {
errors.add("password", new ActionMessage("error.password.required")); }
return errors; }
public String getUserName() { System.out.println("Inside getter
"+userName); return userName; }
public void setUserName(String userName) { System.out.println("Inside
setter "+userName); this.userName = userName; }
public String getPassword() { return password; }
public void setPassword(String password) { this.password =
password; }
public String toString() { return "user name: " + getUserName() + "
password " + getPassword(); }}
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE struts-config PUBLIC "-//Apache
Software Foundation//DTD Struts Configuration 1.3//EN"
"http://struts.apache.org/struts/dtds/struts-config_1_3.dtd">
<struts-config>
<form-beans> <form-bean name="helloForm" type="HelloForm" /> <form-bean name="loginf"
type="LoginForm"/> <form-bean name="HelloWorldForm" type="HelloWorldForm"/> </form-beans>
<action-mappings> <action path="/hello" type="HelloAction" name="helloForm" input="index.jsp">
<forward name="success" path="/helloStruts.jsp" /> </action>
<action input="/login.jsp" name="loginf" path="/Login" scope="session" type="LoginAction">
<forward name="success" path="/success.jsp" /> <forward name="failure" path="/failure.jsp" />
</action>
<action input="/index2.jsp" name="HelloWorldForm" path="/helloworld" scope="session"
type="HelloWorldAction"> <forward name="success" path="/helloWorld.jsp" />
</action> </action-mappings>
<message-resources parameter="ApplicationResource"/><message-resources
parameter="Resources" /></struts-config>
ApplicationResource.properties
error.userName.required = User Name is required.error.password.required =
Password is required.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org