@@ -40,28 +40,38 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
40
40
String a6 = request .getParameter ("venue" );
41
41
String a7 = request .getParameter ("date" );
42
42
43
- try {
44
- Class .forName ("com.mysql.cj.jdbc.Driver" );
45
- String conURL = "jdbc:mysql://localhost:3306/EventlyDB" ;
46
- String userName = "root" ;
47
- String userPassword = "abc" ;
48
- Connection con = DriverManager .getConnection (conURL , userName , userPassword );
49
- con .setAutoCommit (false );
50
-
51
- Statement statement = con .createStatement ();
52
- String queryStatement = "insert into Event values('" +a1 +"','" +a2 +"','" +a3 +"','" +a4 +"','" +a5 +"','" +a6 +"','" +a7 +"')" ;
53
- statement .executeUpdate (queryStatement );
54
- RequestDispatcher requestDispatcher = request .getRequestDispatcher ("CreateE.html" );
55
- requestDispatcher .include (request , response );
43
+ if (a1 .isBlank () && a2 .isBlank () && a3 .isBlank () && a4 .isBlank () && a5 .isBlank () && a6 .isBlank () && a7 .isBlank ()){
44
+ response .setContentType ("text/html" );
45
+ out .println ("<script type=\" text/javascript\" >" );
46
+ out .println ("alert('Please Enter Event Details!!!');" );
47
+ out .println ("</script>" );
48
+ RequestDispatcher requestDispatcher = request .getRequestDispatcher ("CreateE.html" );
49
+ requestDispatcher .include (request , response );
50
+ }else {
51
+ try {
52
+ Class .forName ("com.mysql.cj.jdbc.Driver" );
53
+ String conURL = "jdbc:mysql://localhost:3306/EventlyDB" ;
54
+ String userName = "root" ;
55
+ String userPassword = "abc" ;
56
+ Connection con = DriverManager .getConnection (conURL , userName , userPassword );
57
+ con .setAutoCommit (false );
58
+
59
+ Statement statement = con .createStatement ();
60
+ String queryStatement = "insert into Event values('" +a1 +"','" +a2 +"','" +a3 +"','" +a4 +"','" +a5 +"','" +a6 +"','" +a7 +"')" ;
61
+ statement .executeUpdate (queryStatement );
62
+ RequestDispatcher requestDispatcher = request .getRequestDispatcher ("CreateE.html" );
63
+ requestDispatcher .include (request , response );
64
+
65
+ out .println ("<br><center><h3> Event Added</h3></center>" );
66
+ System .out .println ("Added to the database!!!" );
67
+ con .commit ();
68
+ con .close ();
69
+ }catch (ServletException | IOException | ClassNotFoundException | SQLException e ){
70
+ System .out .println ("Exception caught: " + e );
71
+ }
56
72
57
- out .println ("<br><center><h3> Event Added</h3></center>" );
58
- System .out .println ("Added to the database!!!" );
59
- con .commit ();
60
- con .close ();
61
- }catch (ServletException | IOException | ClassNotFoundException | SQLException e ){
62
- System .out .println ("Exception caught: " + e );
63
73
}
74
+
64
75
}
65
76
66
-
67
77
}
0 commit comments