@@ -38,23 +38,32 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
38
38
String a5 = request .getParameter ("cvv" );
39
39
String a6 = request .getParameter ("cname" );
40
40
41
- try {
42
- Class .forName ("com.mysql.cj.jdbc.Driver" );
43
- String conURL = "jdbc:mysql://localhost:3306/EventlyDB" ;
44
- String dbusername = "root" ;
45
- String dbuserpassword = "abc" ;
46
- Connection con ;
47
- con = DriverManager .getConnection (conURL , dbusername , dbuserpassword );
48
- con .setAutoCommit (false );
49
- Statement statement = con .createStatement ();
50
- String mysqlQuery = "insert into card values('" +a1 +"','" +a2 +"','" +a3 +"','" +a4 +"','" +a5 +"','" +a6 +"') " ;
51
- statement .executeUpdate (mysqlQuery );
52
- con .commit ();
53
- con .close ();
54
- RequestDispatcher requestDispatcher = request .getRequestDispatcher ("Payment.html" );
55
- requestDispatcher .forward (request , response );
56
- }catch (ServletException | IOException | ClassNotFoundException | SQLException e ){
57
- System .out .println ("Exception Caught: " + e );
41
+ if (a1 .isBlank () && a2 .isBlank () && a3 .isBlank () && a4 .isBlank () && a5 .isBlank () && a6 .isBlank ()){
42
+ response .setContentType ("text/html" );
43
+ out .println ("<script type=\" text/javascript\" >" );
44
+ out .println ("alert('Please Enter Event Details!!!');" );
45
+ out .println ("</script>" );
46
+ RequestDispatcher requestDispatcher = request .getRequestDispatcher ("Registration.html" );
47
+ requestDispatcher .include (request , response );
48
+ }else {
49
+ try {
50
+ Class .forName ("com.mysql.cj.jdbc.Driver" );
51
+ String conURL = "jdbc:mysql://localhost:3306/EventlyDB" ;
52
+ String dbusername = "root" ;
53
+ String dbuserpassword = "abc" ;
54
+ Connection con ;
55
+ con = DriverManager .getConnection (conURL , dbusername , dbuserpassword );
56
+ con .setAutoCommit (false );
57
+ Statement statement = con .createStatement ();
58
+ String mysqlQuery = "insert into card values('" +a1 +"','" +a2 +"','" +a3 +"','" +a4 +"','" +a5 +"','" +a6 +"') " ;
59
+ statement .executeUpdate (mysqlQuery );
60
+ RequestDispatcher requestDispatcher = request .getRequestDispatcher ("Payment.html" );
61
+ requestDispatcher .forward (request , response );
62
+ con .commit ();
63
+ con .close ();
64
+ }catch (ServletException | IOException | ClassNotFoundException | SQLException e ){
65
+ System .out .println ("Exception Caught: " + e );
66
+ }
58
67
}
59
68
60
69
}
0 commit comments