-
Notifications
You must be signed in to change notification settings - Fork 0
/
accessDenied.jsp
47 lines (44 loc) · 1.41 KB
/
accessDenied.jsp
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
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="javax.servlet.http.HttpSession" %>
<%
String role = (String) session.getAttribute("role");
String redirectPage = "login.jsp"; // Default redirect
// Determine redirect based on role
if ("admin".equals(role)) {
redirectPage = "adminDashboard.jsp";
} else if ("candidate".equals(role)) {
redirectPage = "candidateDashboard.jsp";
} else if ("voter".equals(role)) {
redirectPage = "voterDashboard.jsp";
}
%>
<html>
<head>
<title>Access Denied</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<%
String username = (session != null) ? (String) session.getAttribute("username") : null; // Get the username if session exists
%>
<nav>
<div class="logo">Pollify</div>
<div class="menu">
<% if(username==null){ %>
<a href="home.jsp">Home</a>
<a href="register.jsp">Register</a>
<a href="login.jsp">Login</a>
<% } %>
<% if (username != null) { %>
<a >Welcome, <%= username %>!</a>
<a href="logout.jsp">Logout</a> <!-- Link to logout servlet -->
<% } %>
</div>
</nav>
<div class="container">
<h2>Access Denied</h2>
<p>You do not have permission to access this page.</p>
<a href="<%= redirectPage %>">Go to Dashboard</a>
</div>
</body>
</html>