In my jsp page I have a jsp button like this.
<input class="submit_button" type="submit" name="Payment" value="Payment"
style="position: absolute; left: 350px; top: 130px;"
onclick="javascript:payment();">
And I have onclick javascript function which call the jsp method "callProcedure()" like this.
<script>
function payment(){
alert('Payment done successfully...');
<%
callProcedure(); // calls the procedure
%>
</script>
And the jsp method callProcedure() calls the oracle procedure like this
<%! void callProcedure() {
CallableStatement cst = null;
Connection conn = null;
try {
DBDataSource dbDataSource = new DBDataSource();
conn = dbDataSource.makeConnection();
conn.setAutoCommit(false);
String insertStoreProc = "{call
p_webservice_test(?,?,?,?,?,?,?,?,?,?,?,?,?,?)}";
cst = conn.prepareCall(insertStoreProc);
cst.setString(1, TransID);
cst.setString(2, RemitNo);
cst.setString(3, senderFName + senderMName + senderLName);
cst.setString(4, RFName + RMName + RLName);
cst.setString(5, RAddr);
cst.setString(6, RPh);
cst.setString(7, Relshp);
cst.setString(8, tDate.toString());
cst.setString(9, PayCur);
cst.setBigDecimal(10, paymentAmt);
cst.setString(11, Pcode);
cst.registerOutParameter(12, Types.VARCHAR);
cst.executeUpdate();
conn.commit();
} catch (SQLException e) {
System.out.println("Error:::" + e.getMessage());
} finally {
if (cst != null) {
try {
cst.close();
} catch (Exception ex) {
System.out.println("Error:" + ex.getMessage());
}
}
}
}
%>
Here, my problem is that the jsp method "callProcedure()" execute before clicking the button or before executing the javascript method. Whats the exact problem and the solution for this problem. Please reply as soon as possible.
Thanks In Advance...