-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathVaPa.java
More file actions
71 lines (64 loc) · 2.77 KB
/
Copy pathVaPa.java
File metadata and controls
71 lines (64 loc) · 2.77 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
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
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/JSP_Servlet/Servlet.java to edit this template
*/
/**
/*
* @author adrianadewunmi
* Participant Login Validation Servlet
* for registering new participants.
*/
import java.io.*;
import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
* @author adrianadewunmi
*/
public class VaPa extends HttpServlet {
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
try (PrintWriter out = response.getWriter()) {
String userName = request.getParameter("Pausername");
String userPassword = request.getParameter("Papassword");
if(userName.isBlank() && userPassword.isBlank()){
response.setContentType("text/html");
out.println("<script type=\"text/javascript\">");
out.println("alert('Please Enter Your Login Details!!!');");
out.println("</script>");
RequestDispatcher requestDispatcher = request.getRequestDispatcher("Plogin.html");
requestDispatcher.include(request, response);
}else{
try {
if(LoginDao.validate(userName, userPassword)){
RequestDispatcher requestDispatcher = request.getRequestDispatcher("ParticipantEvent.html");
requestDispatcher.forward(request, response);
}else{
response.setContentType("text/html");
out.println("<script type=\"text/javascript\">");
out.println("alert('Sorry! ... User Name and Password Incorrect!!!');");
out.println("</script>");
RequestDispatcher requestDispatcher = request.getRequestDispatcher("Plogin.html");
requestDispatcher.include(request, response);
}
} catch (SQLException ex) {
Logger.getLogger(VaPa.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
}