File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Validation error mesage is not display in browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation error mesage is not display in browser" Watch "Validation error mesage is not display in browser" New topic

Validation error mesage is not display in browser

Piraba Sivakadadcham

Joined: Nov 07, 2008
Posts: 6
Hi All;

Please help me.This is my issue: I amnew struts2.Its going inside the validate() , but not display in browser.

Action class is:

public class UserAction extends ActionSupport {
private CountryDAO countryDAO = new CountryDAO();
private List<User> lstUser;
private User user;
private UserDAO userDAO = new UserDAO();

public UserAction(){

public User getUser() {
return user;

public void setUser(User user) {
this.user = user;

public String execute(){
try {
userDAO.persisteUserCountry(getUser().getCountry().getName(), user);
}catch(Exception e) {
System.out.println("----" + e.getMessage());
return SUCCESS;

public void validate(){

if(getUser().getUsername().length() == 0){
addActionMessage("User Name is required");

if(getUser().getPassword().length() == 0){
addActionMessage("Password is required");

if(getUser().getPassword().length() > 6){
addActionMessage( "Minimum passsword length is 6");

System.out.println("###########" + this.hasActionMessages());


My Jsp is like this:


<div id="result">Submit form bellow.</div>
<s:form action="accountTypeAction" >

<s:textfield name="user.username" label="Email" required="true" />
<!-- <s:textfield name="confirmEmail" key="label.confirmmail" size="20" /> -->
<s:password name="user.password" label="Password" required="true"/>

<s:select name="user.accountType" label="Account Type" list="#{'peronal':'peronal','company':'company'}" />
<s:select label="Country of residence" name="" headerKey="- - -"
headerValue="Select Country"
listValue="name" />

and struts.xml is :
<include file="struts-default.xml"/>

<!-- Configuration for the default package. -->

<package name="default" extends="struts-default">

<action name="accountType" class="com.providence.pgw.action.CountryAction">
<result name="success">userAccountType.jsp</result>

<action name="accountTypeAction" class="com.providence.pgw.action.UserAction">
<result name="input" type="redirect-action">accountType</result>
<result name="error" type="redirect-action">accountType</result>
<result name="success" >emailVarification.jsp</result>

<action name="emailVerify" class="com.providence.pgw.action.UserAction" method="displayPersonalInfo">
<interceptor-ref name="params" />
<interceptor-ref name="validation">
<param name="excludeMethods">displayPersonalInfo</param>
<result name="input" >activationKeyExit.jsp</result>
<result name="error" >errorActivationKey.jsp</result>
<result name="success">personalDetails.jsp</result>


When I submit the form its going inside the validate method and redirect to input. But not display error message in browser.

Please anybody help me soon.

Thanks for advancce.

Ankit Garg

Joined: Aug 03, 2008
Posts: 9465

Piraba please UseCodeTags when you post a source code.

I don't know why the code is not working (might be because of your interceptor configuration) but generally addFieldError method is used if you want to add an error message for a particular field...

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
I agree. Here's the link:
subject: Validation error mesage is not display in browser
It's not a secret anymore!