
Hi good morning Sir,

1)approveApplication.jsp:
<%@ page import="java.sql.*" %>
<html>
<script>
function check(v){
var f=document.form;
f.method="post";
f.action='approve.jsp?id='+v;
f.submit();
}
function check_all_in_document(doc)
{
var c = new Array();
c = doc.getElementsByTagName('input');
for (var i = 0; i < c.length; i++)
{
if (c[i].type == 'checkbox')
{
c[i].checked = true;
}
}
}
function checkAll()
{
check_all_in_document(window.document);
for (var j = 0; j < window.frames.length; j++)
{
check_all_in_document(window.frames[j].document);
}
}
</script>
<form name="form" method="post" action="approveall.jsp" onsubmit="return checkem();">
<table border="1">
<tr><th>ID</th><th>Name</th><th>Status</th><th></th></tr>
<%
int i=0;
Connection con = null;
String url = "jdbc:mysql://localhost:3306/";
String db = "test";
String driver = "com.mysql.jdbc.Driver";
String userName ="root";
String password="root";
int sumcount=0;
Statement st;
try{
Class.forName(driver).newInstance();
con = DriverManager.getConnection(url+db,userName,password);
String query = "select * from employee";
st = con.createStatement();
ResultSet rs = st.executeQuery(query);
%>
<%
while(rs.next()){
%>
<tr>
<td><input type="text" name="id" value="<%=rs.getString("id")%>"></td>
<td><input type="text" name="name" value="<%=rs.getString("name")%>"></td>
<td><input type="text" name="status" value="<%=rs.getString("status")%>"></td>
<td><input type="checkbox" value="<%=rs.getString("id")%>" onclick='check(<%=rs.getString("id")%>);' name="checkboxes"></td>
</tr>
<%
}
%>
<%
}
catch(Exception e){
e.printStackTrace();
}
%>
</table>
<input type="submit" value="Approve All">
</form>
</html>

2)approve.jsp:
<%@ page import="java.sql.*" %>
<%
String value=request.getParameter("id");
int id=Integer.parseInt(value);
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=conn.createStatement();
int i=st.executeUpdate("update employee set status='Approve' where id="+id+"");
response.sendRedirect("/examples/jsp/Example2/approveApplication.jsp");
%>
3)approveall.jsp:
<%@ page import="java.sql.*" %>
<%
String values[]=request.getParameterValues("checkboxes");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root", "root");
Statement st=conn.createStatement();
for(int i=0;i<values.length; i++){
int id=Integer.parseInt(values[i]);
st.executeUpdate("update employee set status='Approve' where id="+id+"");
}
response.sendRedirect("/examples/jsp/Example2/approveApplication.jsp");
%>
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.