-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateStatusServlet.java
More file actions
39 lines (31 loc) · 1.34 KB
/
UpdateStatusServlet.java
File metadata and controls
39 lines (31 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package com.system.controllers;
import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
@WebServlet("/UpdateStatusServlet")
public class UpdateStatusServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int appId = Integer.parseInt(request.getParameter("applicationId"));
String status = request.getParameter("status");
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/employer_worker_system", "root", "your_password"
);
String sql = "UPDATE job_applications SET status = ? WHERE id = ?";
PreparedStatement stmt = conn.prepareStatement(sql);
stmt.setString(1, status);
stmt.setInt(2, appId);
stmt.executeUpdate();
stmt.close(); conn.close();
response.sendRedirect("jsp/manage_applicants.jsp");
} catch (Exception e) {
e.printStackTrace();
response.getWriter().println("Error updating status: " + e.getMessage());
}
}
}