title: Validation inside Java class in Struts 2
body: <p>I am going to pass error message from inside the Java class to JSP and this error message is written in <code>.properties</code> file. </p>
  
  <p>I am using action class method <code>addActionError(result)</code> to display that error message but it is displaying the message as <code>error.register.bademail</code> in JSP. This is not my written message.</p>
  
  <p><strong>Java class:</strong></p>
  
  <pre><code>package com.uttarainfo.s2;
  public class Model {
  
      public List&lt;String&gt; register(RegBean bean) {
          if(bean.getEmail().equals("bond@gmail.com"))
              return "error.register.bademail"; i want to return this key 
          else
              return "success";
      }
  
  }
  </code></pre>
  
  <p><strong>Action class:</strong></p>
  
  <pre><code>if(result.equals(SUCCESS))
      return SUCCESS;
  else
  {
      addActionError(result);
      return "failure";
  }
  </code></pre>
  
  <p><strong>This is JSP code:</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;%@ taglib uri="/struts-tags" prefix="s" %&gt;    
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
  &lt;title&gt;Insert title here&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Register&lt;/h1&gt;
      &lt;s:form action="register"  method="post" enctype="multipart/form-data"&gt;
          &lt;s:textfield key="bean.uname"/&gt;
          &lt;s:textfield key="bean.email"/&gt;
          &lt;s:password key="bean.pwd"/&gt;
          &lt;s:password key="bean.rpwd"/&gt;
          &lt;s:file key="bean.pic"/&gt;
          &lt;s:submit/&gt;
          &lt;s:actionerror/&gt;
      &lt;/s:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>