-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.java
57 lines (45 loc) · 1.7 KB
/
app.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
package com.app;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.model.Account;
public class app extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action=request.getParameter("action");
if(action==null){
request.getRequestDispatcher("login.jsp").forward(request, response);
}
else
doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action=request.getParameter("action");
if(action.equals("login")){
String email=request.getParameter("email");
String password=request.getParameter("password");
Account account = new Account();
boolean status=false;
try {
status = account.doLogin(email,password);
} catch (Exception e) {}
if(status== true){
HttpSession session = request.getSession();
session.setAttribute("email", email);
request.getRequestDispatcher("index.jsp").forward(request, response);
}
else{
request.setAttribute("msg", "Invalid Login");
request.getRequestDispatcher("login.jsp").forward(request, response);
}
}
if(action.equals("category")){
String cat_id=request.getParameter("cat_id");
request.setAttribute("loc", cat_id);
request.getRequestDispatcher("details.jsp").forward(request, response);
}
}
}