File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Pop up error while using validation in struts2.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Pop up error while using validation in struts2.0" Watch "Pop up error while using validation in struts2.0" New topic

Pop up error while using validation in struts2.0

Rajiv Pamidimukkala

Joined: Feb 21, 2008
Posts: 1
I have wriiten a small application using struts 2.0...and then i have tried to implement validation in it.I have given 2 input fields, and when i click on submit without entereing in one of the fields or both, i get a pop-up stating that [object-error].

Kindly, help me out in this...the code is given below...
Thanks in advance.


<meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>


<s:form action="loginAction" validate="true">

Username: <s:textfield name="username"/>
Password: <s assword name="password"/>

<s:submit value="submit"/>



<field name="username">

<field-validator type="required">
<param name="fieldName">username</param>

<!--<param name="trim">true</param>-->

<message>Login name is required</message>



<field name="password">

<field-validator type="requiredstring">

<!--<param name="trim">true</param>-->

<message>Password is required</message>





public class loginAction extends ActionSupport{

String username;
String password;
public String execute()throws Exception{

System.out.println("Validating login");
if(!getUsername().equals("Admin") || !getPassword().equals("Admin")){
addActionError("Invalid user name or password! Please try again!");
return "ERROR";
return "SUCCESS";


public void setUsername(String username) {
this.username = username;

public String getUsername() {
return username;

public void setPassword(String password) {
this.password = password;

public String getPassword() {
return password;

does anyone to solve it....
I agree. Here's the link:
subject: Pop up error while using validation in struts2.0
It's not a secret anymore!