• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
  • Tim Holloway
  • Carey Brown
  • salvin francis

not validating

Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have created one project in netbeans...
files are :--
Employee-Validation.xmland one class Employee.java
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 employee.java
* 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) {
this.email = email;
public String getMobile() {
return mobile;
public void setMobile(String mobile) {
this.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="http://www.w3.org/2001/XMLSchema-instance"
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
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
What are your superhero powers? Go ahead and try them on this tiny ad:
professionally read, modify and write PDF files from Java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!