-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorderrentservlet.java
69 lines (64 loc) · 2.34 KB
/
orderrentservlet.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
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/**
* Servlet implementation class orderrentservlet
*/
@WebServlet("/orderrentservlet")
public class orderrentservlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter pw=response.getWriter();
String name,address,email,location,proof,modelname,duration,price,status,phonenumber,date,studioname;
name=request.getParameter("name");
address=request.getParameter("address");
email=request.getParameter("email");
location=request.getParameter("location");
modelname=request.getParameter("modelname");
duration=request.getParameter("duration");
price=request.getParameter("price");
studioname=request.getParameter("studioname");
phonenumber=request.getParameter("phonenumber");
HttpSession ses3=request.getSession();
proof=String.valueOf(ses3.getAttribute("proof"));
date=String.valueOf(ses3.getAttribute("date"));
status="Waiting";
int id=0;
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bootathon2","db","java");
PreparedStatement ps=con.prepareStatement("insert into order_rent values(?,?,?,?,?,?,?,?,?,?,?,?,?)");
ps.setInt(1, id);
ps.setString(2, name);
ps.setString(3, studioname);
ps.setString(4, email);
ps.setString(5, address);
ps.setString(6, location);
ps.setString(7, modelname);
ps.setString(8,duration);
ps.setString(9, date);
ps.setString(10, price);
ps.setString(11, proof);
ps.setString(12, phonenumber);
ps.setString(13, status);
ps.executeUpdate();
RequestDispatcher rd=getServletContext().getRequestDispatcher("/enquiry.jsp");
rd.forward(request,response);
con.close();
}
catch(Exception e)
{
System.out.print(e);
}
}
}