• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

problem in struts2 validation

Posts: 12
  • Mark post as helpful
  • send pies
  • 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
  • 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.


They gave me pumpkin ice cream. It was not pumpkin pie ice cream. Wiping my tongue on this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
    Bookmark Topic Watch Topic
  • New Topic