-
Notifications
You must be signed in to change notification settings - Fork 0
/
RegistrationServlet.java
78 lines (53 loc) · 2.19 KB
/
RegistrationServlet.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
package servelets;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import transferObject.UserDTO;
import transferObject.UserType;
import java.io.IOException;
import buisnessLayer.UserBuisnessLogic;
/**
* Servlet implementation class RegistrationServlet
*/
@WebServlet("/RegistrationServlet")
public class RegistrationServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
UserBuisnessLogic userRegistration;
UserDTO user;
public RegistrationServlet() {
userRegistration = new UserBuisnessLogic();
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String firstName = request.getParameter("firstName");
String lastName = request.getParameter("lastName");
String email = request.getParameter("email");
String password = request.getParameter("password");
String userType = request.getParameter("userType");
String joinDate = request.getParameter("joinDate");
String subscribe = request.getParameter("subscribe");
boolean isSubscribe = false;
if(subscribe=="yes") isSubscribe=true;
String notificationMethod = null;
// Check if user subscribed to alerts and retrieve the selected notification method
if (subscribe != null && subscribe.equals("Yes")) {
// Check if SMS notification is selected
if (request.getParameter("smsNotification") != null) {
notificationMethod = "sms";
}
// Check if Email notification is selected
else if (request.getParameter("emailNotification") != null) {
notificationMethod = "email";
}
}
//Registering User
user = new UserDTO(firstName,lastName,password,email,joinDate,userType);
// adding to database.. by buisnessLogic
userRegistration.addUser(user);
response.sendRedirect(request.getContextPath() + "/LoginServlet");
}
}