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