Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Validation error mesage is not display in browser  RSS feed

Piraba Sivakadadcham
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9610
Android Google Web Toolkit Hibernate IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!