Author
java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st
kuamit kumar
Greenhorn
Joined: Jul 15, 2009
Posts: 1
hi ,
I am trying to validate my page for null value , it is giving following error ...Please suggest ASAP
java.lang.ClassCastException : org.apache.struts.action.ActionMessage cannot be cast to org.apache.struts.action.ActionError
org.apache.struts.taglib.html.ErrorsTag.doStartTag(ErrorsTag.java:215)
org.apache.jsp.login_jsp._jspx_meth_html_005ferrors_005f0(login_jsp.java:139)
org.apache.jsp.login_jsp._jspx_meth_html_005fhtml_005f0(login_jsp.java:109)
org.apache.jsp.login_jsp._jspService(login_jsp.java:74)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.struts.action.RequestProcessor.doForward(RequestProcessor.java:1069)
org.apache.struts.action.RequestProcessor.internalModuleRelativeForward(RequestProcessor.java:1012)
org.apache.struts.action.RequestProcessor.processValidate(RequestProcessor.java:980)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:255)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:647)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
my Form is
public class LoginForm extends ActionForm {
private String userName="";
private String password="";
private String email="";
private int age=0;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors err = new ActionErrors();
if (userName == null || "".equals(userName)) {
err.add(userName, new ActionMessage("error.userName.required"));
}
if (password == null || "".equals(password)) {
err.add(password, new ActionMessage("error.password.required"));
}
return err;
}
public void reset(ActionMapping mapping, HttpServletRequest request){
userName=null;
password=null;
}
}
and jsp page is
<%@taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<html:html>
<head>
<title>Login Page</title>
</head>
<body>
<html:errors/>
<html:form action="/Login">
User Name :<html:text name="LoginForm" property="userName" /> <br>
Password :<html:password name="LoginForm" property="password" /><br>
<html:submit value="Login" />
</html:form>
</body>
</html:html>
please suggest, if anybody has some idea .Thanks!
David Newton
Author
Rancher
Joined: Sep 29, 2008
Posts: 12617
posted Dec 24, 2009 06:22:38
0
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
subject: java.lang.ClassCastException: org.apache.struts.action.ActionMessage cannot be cast to org.apache.st