I am new to calling a REST service in a JSP. I have a form which goes through a struts2 action. I have a javascript function which performs a basic email validation. So instead of performing this validation using JavaScript I need to call a service which does email validation.
Do I need to call the validation service directly in JSP page if not then how can I achieve this.
<form name="resendEsignatureFormId" id="resendEsignatureFormId" action="<integration:urlAction actionName='/integration/resendEsignatureIntegration'></integration:urlAction>"
method="POST">
</form>
JavaScript function
function validate() {
// Need to call validation service here
document.getElementById('resendEsignatureFormId').submit();
}
<table width=100%>
<tr><td class="esignNavigation">
<a href="#x" onclick ="validate()"><span>Confirm</span></a>
<a href="#x" onclick="hideSigners()"><span>Cancel</span></a></td>
</tr>
</table>
Thanks in advance...
JSP is a java server-side technology to generate HTML on the server. A javascript call to a REST api is a browser -> server operation. So you don't call a REST service in a JSP, you call a REST service from javascript. That javascript can be invoked by an HTML event (onclick, etc.), and that HTML event may be described in a JSP - regardless of wether or not that event is dynamically generated by the JSP or just hard-coded.
You don't explicitly state that you have a server-side endpoint exposed to perform the email validation - you would need that as well.