-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloan_request.java
129 lines (100 loc) · 4.64 KB
/
loan_request.java
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.Statement;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
*
* @author lenovo1
*/
public class loan_request extends HttpServlet {
Connection cn=null;
Statement st=null;
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
Database db=new Database();
String result=db.Connectdb();
System.out.println(result);
HttpSession session = req.getSession();
PrintWriter out = resp.getWriter();
String user_id = req.getParameter("user_id");
String id=req.getParameter("id");
String status=req.getParameter("status");
String event=req.getParameter("submit");
out.println(user_id);
out.println(id);
out.println(status);
if(event.equals("approved"))
{
if(status.equals("approved"))
{
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('Loan has been already approved and cheque book number is assigned'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
else
{
try
{
String update = db.update("update loan set status='approved' where (user_id='"+user_id+"' && id='"+id+"' ) ");
out.println(update);
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('"+update+"'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
catch(Exception ex)
{
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('"+ex.toString()+"'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
}
}
if(event.equals("Rejected"))
{
if(status.equals("Rejected"))
{
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('Loan has been already Rejected'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
else
{
try
{
String update = db.update("update loan set status='Reject' where ( id='"+id+"' ) ");
out.println(update);
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('"+update+"'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
catch(Exception ex)
{
resp.setContentType("text/html");
out.println(" <script type=\"text/javascript\"> ");
out.println(" alert('"+ex.toString()+"'); ");
out.println(" location='loan_request.jsp'; ");
out.println(" </script> ");
}
}
}
}
}