• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

problem in struts2 validation

Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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>
Ranch Hand
Posts: 300
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Parthiban,

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


Willie Smits can speak 40 languages. This tiny ad can speak only one:
a bit of art, as a gift, the permaculture playing cards
    Bookmark Topic Watch Topic
  • New Topic