wood burning stoves 2.0*
The moose likes Struts and the fly likes Struts Validation not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts Validation not working" Watch "Struts Validation not working" New topic
Author

Struts Validation not working

kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
Hi,

I have written below sample program for struts validation attached here. When I submit the form, the validation is not happening. Can anyone take a look and let me know what the issue was.

struts-config.xml


validation.xml



ApplicationResources

errors.suffix=

errors.required='{0} is required'.
errors.minlength='{0} can not be less than {1} characters'.
errors.range='{0} is not in the range {1} through {2}'.

exampleForm.name=Name
exampleForm.age=Age


web.xml



ExampleAction.java



Ex1.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<head>
<title>JSP for exampleForm</title>
</head>
<body bgcolor="cyan">
<center>
<html:form action="example1.do">
<html:errors/>
Name : <html:text property="name" />

Age : <html:text property="age" />

<html:submit value="Send"/>
</html:form>
</center>
</body>
</html>


Ex2.jsp

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<head>
<title>JSP for exampleForm</title>
</head>
<body bgcolor="yellow">
<center>
<html:form action="example2.do">
<html:errors/>
Name : <html:text property="name" />

Age : <html:text property="age" />

<html:submit value="Send"/>
</html:form>
</center>
</body>
</html>



Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Hi Suresh,

Please check validation.xml you shown in your post, please correct it.


Thanks,
Shailesh
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
What is the correction under validation.xml
Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
It is struts-config.xml you placed in place of validation.xml.
kalle suresh
Ranch Hand

Joined: Nov 20, 2007
Posts: 48
Hi,

By mistake I placed the struts-config.xml twice. Below attached is my validation.xml

Shailesh Narkhede
Ranch Hand

Joined: Jul 10, 2008
Posts: 368
Are you put validator-rules.xml xml in your WEB-INF as you mentioned in struts-config.xml.

you can get nice example for validator framework HERE
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts Validation not working
 
Similar Threads
tomcat problem.
"Cannot retrieve definition for form bean" error
error comes while running the struts application please see the source code for detail
Cannot find ActionMappings or ActionFormBeans collection
Error while trying NewsLetter Example