I am a newbie in JSP. I am creating a table that shows the notification approval. The function of it is to show whether the admin approves the record or not. However, when I click on the Accept button, nothing changed (both the page and the database remain 0). Is there any error in my code?? Please help. Thank you in advance.
The Javascript in my JSP file:
<script language="JavaScript">
function submitaccept(){
String connectionURL = "jdbc:mysql://localhost/ams";
Connection connection =null;
PreparedStatement pstatement = null;
var sqlstr = "UPDATE notification SET ack_flag = 1 WHERE notification_id = 001;";
connection = DriverManager.getConnection(connectionURL, "root", "");
pstatement =connection.prepareStatement(sqlstr);
pstatement.executeUpdate();
location.reload(true);
}
The call function of my JSP file:
<c:choose>
<c:when test="${row.ack_flag=='0'}">
<a href="javascript:submitaccept()" >
Approve</a> |
<a href="notification.jsp" >
Reject </a>
</c:when>
<c:when test="${row.ack_flag=='1'}">
Approved
</c:when>
<c:otherwise>
Rejected
</c:otherwise>
</c:choose>