File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes not validating Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "not validating" Watch "not validating" New topic

not validating

vinayGuddu Pandey
Ranch Hand

Joined: Aug 02, 2012
Posts: 30
I have created one project in netbeans...
files are :--
Employee-Validation.xmland one class
now when i am running the project after submitting the form it should validate all fields but it is not validating directly it is submitting the form without validation.

this is index.jsp
<h2>Registration </h2>
<s:form action="empinfo" method="POST">
<s:textfield name="username" label="Username "/>
<s:password name="password" label="Password "/>
<s:password name="confirmPassword" label="Confirm Password "/>
<s:textfield name="email" label="Email Address " />
<s:textfield name="mobile" label="Mobile Number " />
<s:submit value="Register"/>

this is success.jsp

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<%@ taglib prefix="s" uri="/struts-tags" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Registration Completed</title>
Thank you <s:property value="username"/> for registering.

this is Employee-Validation.xml file

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE validators PUBLIC
"-//OpenSymphony Group//XWork Validator 1.0.2//EN"
<field name="username">
<field-validator type="requiredstring">
<message>Username is required </message>
<field name="password">
<field-validator type="requiredstring">
<message>Password is required </message>

<field-validator type="stringlength">
<param name="minLength">5</param>
<message>Password must contain at least ${minLength} characters</message>
<field name="email">
<field-validator type="email">
<message>Email address is not valid</message>
<field-validator type="requiredstring">
<message>Email address is required!</message>

<field name="mobile">
<field-validator type="regex">
<param name="expression">^[0-9]{10}$</param>
<message>Mobile number must be of 10 digits</message>

<validator type="expression">
<param name="expression">password == confirmPassword</param>
<message>Password and confirm password do not match!</message>

this is
* To change this template, choose Tools | Templates
* and open the template in the editor.
package com.valiadtor.form.vinay;

* @author dell
import com.opensymphony.xwork2.ActionSupport;
public class Employee extends ActionSupport {
private String username,password,confirmPassword,email,mobile;
public String getConfirmPassword() {
return confirmPassword;
public void setConfirmPassword(String confirmPassword) {
this.confirmPassword = confirmPassword;
public String getEmail() {
return email;
public void setEmail(String email) { = email;
public String getMobile() {
return mobile;
public void setMobile(String mobile) { = mobile;
public String getPassword() {
return password;
public void setPassword(String password) {
this.password = password;
public String getUsername() {
return username;
public void setUsername(String username) {
this.username = username;
public Employee() {
public String execute() throws Exception {
// do the required process
return "success";

this is web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi=""
id="WebApp_ID" version="3.0">

<display-name>Struts 2</display-name>



this is struts.xml
<?xml version="1.0" encoding="UTF-8"?>
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<constant name="struts.devMode" value="true" />
<package name="helloworld" extends="struts-default">
<action name="empinfo" class="com.valiadtor.form.vinay.Employee">
<result name="success">/success.jsp</result>
<result name="input">/index.jsp</result>


please help me ................
and please let me know that whether i need to configure my Employee-Validation.xml in web.xml also or not.
I have placed my Employee-Validation.xml file in the same package of .java

vinayGuddu Pandey
Ranch Hand

Joined: Aug 02, 2012
Posts: 30
I got the answer, actually java language is a case sensitive so I need to name my Employee-Validation.xml as a Employee-validation.xml ......its running
I agree. Here's the link:
subject: not validating
It's not a secret anymore!