title: How to check for an unique user with jQuery Ajax in Struts 2?
body: <p>I'm having any application in which I have <code>email_id</code> as unique and when the end user enters his <code>email_id</code> I have fired SQL query through Ajax which check whether this <code>email_id</code> exists or not. Until here it's working fine but now I what if that <code>email_id</code> exists then I want to display it on the JSP page like &quot;This id is already taken&quot; and vice-versa.</p>
  <p>So my question is how to get the response from Struts app and give it to Ajax or JSP page and what to write in <code>struts.xml</code> result tag?</p>
  <p><strong>This is my Ajax call to <code>EmailCheck.action</code>:</strong></p>
  <pre><code>$(&quot;#email&quot;).blur(function() {
        var EmailV = $(&quot;#email&quot;).val();
          if(EmailV.length &gt; 10){
              $('#Loading').show();
              $.get(&quot;EmailCheck.action&quot;, {
                  Email_Id: EmailV   
              }, function(response){
                  $('#Info').fadeOut();
                  $('#Loading').hide();
                  setTimeout(&quot;finishAjax('Info', '&quot;+escape(response)+&quot;')&quot;, 450);
              });
              return false;
          }
      });
  </code></pre>
  <p><strong>This is my <code>struts.xml</code>:</strong></p>
  <p>Should there be result tag for this Email type checker?</p>
  <pre><code> &lt;action name=&quot;EmailCheck&quot;  class=&quot;org.register.customers.EmailCheckAction&quot; method=&quot;EmailCheck&quot;&gt;
            &lt;result name=&quot;input&quot;&gt;index.jsp&lt;/result&gt;
            &lt;result name=&quot;success&quot;&gt;success.jsp&lt;/result&gt;
            &lt;result name=&quot;error&quot;&gt;error.jsp&lt;/result&gt;
    &lt;/action&gt;
  </code></pre>
  <p><strong>This is my <code>Action</code> code:</strong></p>
  <pre><code> public String EmailCheck() throws Exception{
           
       System.out.println(user.getEmail_Id());
  
         boolean create = Check_Email(user);
  
   //  &quot;this is my sql call to check the existence of email&quot;
  
      if (true) {       
         
          return &quot;input&quot;;
      } else {          
          
          return ERROR;
      }        
  }
  </code></pre>