jQuery in Action, 3rd edition
The moose likes Struts and the fly likes problem in struts2 validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problem in struts2 validation" Watch "problem in struts2 validation" New topic

problem in struts2 validation

Parthiban Thangaraju

Joined: Oct 16, 2012
Posts: 12
Dear Friends,

I am facing a problem in validation the form. form is not validated. Kindly any one help me to solve this problem

login action

package com.vaannila.action;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.vaannila.model.Login;
public class LoginAction extends ActionSupport implements ModelDriven {

Login login=new Login();

public String execute() {

return SUCCESS;

public Object getModel(){
return login;


* To change this template, choose Tools | Templates
* and open the template in the editor.
package com.vaannila.model;

import com.opensymphony.xwork2.ActionSupport;

* @author Meyyappan Muthuraman
public class Login implements java.io.Serializable {

private String userName;
private String password;

public Login() {

* @return the userName
public String getUserName() {
return userName;

* @param userName the userName to set
public void setUserName(String userName) {
this.userName = userName;

* @return the password
public String getPassword() {
return password;

* @param password the password to set
public void setPassword(String password) {
this.password = password;


Document : index
Created on : Feb 28, 2009, 9:45:01 AM
Author : Meyyappan Muthuraman

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<%@taglib uri="/struts-tags" prefix="s" %>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Login Page</title>
<s:head />
<s:form action="LoginAction">
<s:textfield name="userName" label="User Name" />
<s:password name="password" label="Password" />
<s:submit value="Login" />


<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
<field name="userName">
<field-validator type="requiredstring">
<message>User Name is required.</message>
<field name="password">
<field-validator type="requiredstring">
<message key="password.required" />


"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"

<!-- Configuration for the default package. -->
<package name="default" extends="struts-default">
<action name="LoginAction" class="com.vaannila.action.LoginAction">
<result name="input">/login.jsp</result>
<result name="success">/success.jsp</result>
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 297

hi Parthiban,

Use code tags , Please. and let us know where you are excatly facing problem. Are you getting error or validation dosent fire.


I agree. Here's the link: http://aspose.com/file-tools
subject: problem in struts2 validation
It's not a secret anymore!