I have two JSP scriptlet function as follows
<%!
public void method1(){
System.out.println("method one");
}
%>
<%!
public void method2(){
System.out.println("method two");
}
%>
I want to call the functions after checking a condition on button click event using JAVASCRIPT like below
<script type="text/javascript">
$('#btnSubmit').click(function(e) {
var partyid=$("#txtPartyName").val();
if(partyid==1){
<%method1();%>
}
else{
<%method2();%>
}
});
</script>
Is this possible or is there any other way to achieve this functionality?