Download as pdf or txt
Download as pdf or txt
You are on page 1of 33

UserRepository.

java Thursday, 22 June, 2023, 7:10 pm

1 package com.vaccination.repositories;
2
3 import org.springframework.data.jpa.repository.JpaRepository;
7
8
9 @Repository
10 public interface UserRepository extends JpaRepository<UserCredentials, Integer>{
11
12 }
13

Page 1
pom.xml Thursday, 22 June, 2023, 7:08 pm

1 <?xml version="1.0" encoding="UTF-8"?>


2 <project xmlns="http://maven.apache.org/POM/4.0.0"
3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
https://maven.apache.org/xsd/maven-4.0.0.xsd">
5 <modelVersion>4.0.0</modelVersion>
6 <parent>
7 <groupId>org.springframework.boot</groupId>
8 <artifactId>spring-boot-starter-parent</artifactId>
9 <version>3.1.0</version>
10 <relativePath /> <!-- lookup parent from repository -->
11 </parent>
12 <groupId>com.centers</groupId>
13 <artifactId>vaccinationCenters</artifactId>
14 <version>0.0.1-SNAPSHOT</version>
15 <name>vaccinationCenters</name>
16 <description>Demo project for Spring Boot</description>
17 <properties>
18 <java.version>20</java.version>
19 </properties>
20 <dependencies>
21 <dependency>
22 <groupId>org.springframework.boot</groupId>
23 <artifactId>spring-boot-starter-data-jpa</artifactId>
24 </dependency>
25 <dependency>
26 <groupId>org.springframework.boot</groupId>
27 <artifactId>spring-boot-starter-web</artifactId>
28 </dependency>
29
30 <dependency>
31 <groupId>com.microsoft.sqlserver</groupId>
32 <artifactId>mssql-jdbc</artifactId>
33 <scope>runtime</scope>
34 </dependency>
35 <dependency>
36 <groupId>com.mysql</groupId>
37 <artifactId>mysql-connector-j</artifactId>
38 <scope>runtime</scope>
39 </dependency>
40 <!-- JSP support -->
41 <dependency>
42 <groupId>
43 org.apache.tomcat.embed</groupId>
44 <artifactId>tomcat-embed-jasper</artifactId>
45 <scope>
46 provided</scope>
47 </dependency>
48
49 <dependency>
50 <groupId>org.springframework.boot</groupId>
51 <artifactId>spring-boot-starter-test</artifactId>
52 <scope>test</scope>
53 </dependency>
54 </dependencies>
55
56 <build>
57 <plugins>
58 <plugin>

Page 1
pom.xml Thursday, 22 June, 2023, 7:08 pm

59 <groupId>org.springframework.boot</groupId>
60 <artifactId>spring-boot-maven-plugin</artifactId>
61 </plugin>
62 </plugins>
63 </build>
64
65 </project>
66

Page 2
application.properties Thursday, 22 June, 2023, 7:08 pm

1 server.port=8086
2
3
4 #locate jsp files
5 spring.mvc.view.prefix=/WEB-INF/views/
6 spring.mvc.view.suffix=.jsp
7
8 #Database
9 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
10 spring.datasource.url=jdbc:mysql://localhost:3306/vaccinationdb
11 spring.datasource.username=root
12 spring.datasource.password=Ammanana@789
13 spring.jpa.show-sql=true
14 spring.jpa.hibernate.ddl-auto=update
15 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect
16

Page 1
UserCredentials.java Thursday, 22 June, 2023, 7:09 pm

1 package com.vaccination.entities;
2
3 import jakarta.persistence.Entity;
7
8 @Entity
9 public class UserCredentials {
10
11 @Id
12 @GeneratedValue(strategy = GenerationType.IDENTITY)
13 private long id;
14 private String name;
15 private String email;
16 private String password;
17
18 public long getId() {
19 return id;
20 }
21 public String getName() {
22 return name;
23 }
24 public void setName(String name) {
25 this.name = name;
26 }
27 public String getEmail() {
28 return email;
29 }
30 public void setEmail(String email) {
31 this.email = email;
32 }
33 public String getPassword() {
34 return password;
35 }
36 public void setPassword(String password) {
37 this.password = password;
38 }
39
40
41 }
42

Page 1
VaccinationCenters.java Thursday, 22 June, 2023, 7:10 pm

1 package com.vaccination.entities;
2
3 import java.util.List;
11
12 @Entity
13 public class VaccinationCenters {
14
15 @Id
16 @GeneratedValue(strategy = GenerationType.IDENTITY)
17 private Long id;
18 private String name;
19 private String city;
20
21 @OneToMany(mappedBy = "vaccinationCenters", cascade = CascadeType.ALL,
orphanRemoval = true)
22 private List<Citizens> citizens;
23
24 public List<Citizens> getCitizens() {
25 return citizens;
26 }
27
28 public void setCitizens(List<Citizens> citizens) {
29 this.citizens = citizens;
30 }
31
32 public Long getId() {
33 return id;
34 }
35
36 public String getName() {
37 return name;
38 }
39
40 public void setName(String name) {
41 this.name = name;
42 }
43
44 public String getCity() {
45 return city;
46 }
47
48 public void setCity(String city) {
49 this.city = city;
50 }
51
52 }
53

Page 1
Citizens.java Thursday, 22 June, 2023, 7:10 pm

1 package com.vaccination.entities;
2
3 import jakarta.persistence.Column;
10
11 @Entity
12 public class Citizens {
13
14 @Id
15 @GeneratedValue(strategy = GenerationType.IDENTITY)
16 private Long id;
17 @Column(name = "c_name")
18 private String cName;
19 @Column(name = "no_of_doses")
20 private int noOfDoses=0;
21 @Column(name = "vaccination_status")
22 private String vaccinationStatus;
23
24 @ManyToOne
25 @JoinColumn(name = "vaccination_centers_id")
26 private VaccinationCenters vaccinationCenters;
27
28 public Long getId() {
29 return id;
30 }
31
32 public void setId(Long id) {
33 this.id = id;
34 }
35
36
37 public String getcName() {
38 return cName;
39 }
40
41 public void setcName(String cName) {
42 this.cName = cName;
43 }
44
45 public int getNoOfDoses() {
46 return noOfDoses;
47 }
48
49 public void setNoOfDoses(int noOfDoses) {
50 this.noOfDoses = noOfDoses;
51 }
52
53 public String getVaccinationStatus() {
54 return vaccinationStatus;
55 }
56
57 public void setVaccinationStatus(String vaccinationStatus) {
58 this.vaccinationStatus = vaccinationStatus;
59 }
60
61 public VaccinationCenters getVaccinationCenters() {
62 return vaccinationCenters;
63 }
64
65 public void setVaccinationCenters(VaccinationCenters vaccinationCenters) {

Page 1
Citizens.java Thursday, 22 June, 2023, 7:10 pm

66 this.vaccinationCenters = vaccinationCenters;
67 }
68
69
70 }
71

Page 2
UserRepository.java Thursday, 22 June, 2023, 7:10 pm

1 package com.vaccination.repositories;
2
3 import org.springframework.data.jpa.repository.JpaRepository;
7
8
9 @Repository
10 public interface UserRepository extends JpaRepository<UserCredentials, Integer>{
11
12 }
13

Page 1
VaccinationCentersRepo.java Thursday, 22 June, 2023, 7:11 pm

1 package com.vaccination.repositories;
2
3 import java.util.List;
10
11 @Repository
12 public interface VaccinationCentersRepo extends JpaRepository<VaccinationCenters, Long>
{
13
14 @Query("SELECT DISTINCT vc.name FROM VaccinationCenters vc")
15 List<String> findDistinctCenterNames();
16
17 @Query("SELECT DISTINCT vc.city FROM VaccinationCenters vc")
18 List<String> findDistinctCityNames();
19
20 VaccinationCenters findByName(String name);
21
22 }
23

Page 1
CitizensRepository.java Thursday, 22 June, 2023, 7:11 pm

1 package com.vaccination.repositories;
2
3 import org.springframework.data.jpa.repository.JpaRepository;
8
9
10 @Repository
11 public interface CitizensRepository extends JpaRepository<Citizens, Long>{
12 List<Citizens> findByVaccinationCentersId(Long vaccinationCentersId);
13 }
14

Page 1
RegisterUser.java Thursday, 22 June, 2023, 7:11 pm

1 package com.vaccination.controllers;
2
3 import org.springframework.beans.factory.annotation.Autowired;
11
12 @Controller
13 public class RegisterUser {
14
15 @Autowired
16 UserRepository userRepository;
17
18 @GetMapping("/registerUser")
19 public String registerForm() {
20 return "registration";
21 }
22 @PostMapping("/registerUser")
23 public String registerUser(@RequestParam("name") String name,@RequestParam("email")
String email,
24 @RequestParam("password") String password) {
25
26 UserCredentials user = new UserCredentials();
27 user.setName(name);
28 user.setEmail(email);
29 user.setPassword(password);
30
31 userRepository.save(user);
32 return "index";
33
34 }
35
36 }
37

Page 1
UserController.java Thursday, 22 June, 2023, 7:12 pm

1 package com.vaccination.controllers;
2
3 import java.util.List;
14
15 @Controller
16 public class UserController {
17
18 @Autowired
19 UserRepository userRepository;
20
21 @GetMapping("/")
22 public String loginform() {
23 return "index";
24 }
25
26 @PostMapping("/login")
27 public String loginCheck(@RequestParam("email") String email,
@RequestParam("password") String password) {
28 boolean userFound = false;
29 if(email.isBlank()||email.isEmpty()||password.isBlank()||password.isEmpty()) {
30 return "index";
31 }else {
32 List<UserCredentials> users = userRepository.findAll();
33 for(UserCredentials user: users) {
34 if(email.contentEquals(user.getEmail()) && password.contentEquals
(user.getPassword())) {
35 userFound = true;
36 return "redirect:/displayAllCenters";
37 }
38 }
39 }if(!userFound)return "registration";
40 return "in testing";
41 }
42 }
43

Page 1
VaccinationCentersController.java Thursday, 22 June, 2023, 7:12 pm

1 package com.vaccination.controllers;
2
3 import java.util.List;
18
19 @Controller
20 public class VaccinationCentersController {
21
22 @Autowired
23 VaccinationCentersRepo vcRepository;
24
25 @Autowired
26 CitizensRepository citizensReposotory;
27
28 @GetMapping("displayAllCenters")
29 public String displayVC(Model model) {
30
31 List<VaccinationCenters> vcs = vcRepository.findAll();
32 model.addAttribute("vcs", vcs);
33 return "vaccinationcenter";
34 }
35
36 @GetMapping("AddVCform")
37 public String addVCform() {
38 return "addVaccinationCenterForm";
39 }
40
41 @PostMapping("AddVC")
42 public String addVC(@RequestParam("centerCity") String centerCity,
@RequestParam("centerName") String centerName) {
43 VaccinationCenters vc = new VaccinationCenters();
44 vc.setName(centerName);
45 vc.setCity(centerCity);
46 vcRepository.save(vc);
47 return "redirect:/displayAllCenters";
48 }
49
50 @GetMapping("editcenter")
51 public String editVCform(@RequestParam("id") Long id, Model model) {
52
53 Optional<VaccinationCenters> vaccinationCenter = vcRepository.findById(id);
54 VaccinationCenters vaccinationcenter = vaccinationCenter.get();
55 model.addAttribute("vc", vaccinationcenter);
56 return "editvaccinationcenter"; // go to edit-product.jsp
57 }
58
59 @PostMapping("/editcenter")
60 public String updateVaccinationCenter(@ModelAttribute("vc") VaccinationCenters
updatedCenter, @RequestParam("id") Long id) {
61 Optional<VaccinationCenters> optionalCenter = vcRepository.findById(id);
62 if (optionalCenter.isPresent()) {
63 VaccinationCenters existingCenter = optionalCenter.get();
64 existingCenter.setName(updatedCenter.getName());
65 existingCenter.setCity(updatedCenter.getCity());
66 vcRepository.save(existingCenter);
67 }
68 return "redirect:/displayAllCenters";
69 }
70
71 @PostMapping("/deleteCenter")

Page 1
VaccinationCentersController.java Thursday, 22 June, 2023, 7:12 pm

72 public String deleteVaccinationCenter(@RequestParam("id") Long id) {


73 vcRepository.deleteById(id);
74 return "redirect:/displayAllCenters";
75 }
76 @GetMapping("/viewVaccinationCenterInfo")
77 public String viewVCInfo(@RequestParam("id") Long id, Model model) {
78 Optional<VaccinationCenters> vaccinationCenter = vcRepository.findById(id);
79 VaccinationCenters vaccinationcenter = vaccinationCenter.get();
80 List<Citizens> citizensList = citizensReposotory.findByVaccinationCentersId
(id);
81 model.addAttribute("vaccinationcenter", vaccinationcenter);
82 model.addAttribute("citizensList", citizensList);
83
84 return "viewVaccinationCenter";
85
86 }
87 }
88

Page 2
CitizensController.java Thursday, 22 June, 2023, 7:12 pm

1 package com.vaccination.controllers;
2
3 import java.util.List;
19
20 @Controller
21 public class CitizensController {
22
23 @Autowired
24 CitizensRepository citizensRepository;
25 @Autowired
26 VaccinationCentersRepo vcRepo;
27
28 @GetMapping("/displayCitizens")
29 public String displayCitizens(Model model) {
30
31 List<Citizens> citizensList = citizensRepository.findAll();
32 model.addAttribute("citizens", citizensList);
33 return "citizens";
34 }
35
36 @GetMapping("/addCitizen")
37 public String addCitizenForm(Model model) {
38 List<String> centerNames = vcRepo.findDistinctCenterNames();
39 List<String> cityNames = vcRepo.findDistinctCityNames();
40 model.addAttribute("centerNames", centerNames);
41 model.addAttribute("cityNames", cityNames);
42 model.addAttribute("citizen", new Citizens());
43 return "addCitizenForm";
44 }
45
46 @PostMapping("/addCitizen")
47 public String addCitizenSubmit(@ModelAttribute("citizen") Citizens citizen,
48 @RequestParam("vaccinationCenters.name") String centerName) {
49 // Retrieve the VaccinationCenters object based on the centerName
50 VaccinationCenters vaccinationCenter = vcRepo.findByName(centerName);
51
52 // Set the VaccinationCenters object for the citizen
53 citizen.setVaccinationCenters(vaccinationCenter);
54 // setting vaccination status
55 if (citizen.getNoOfDoses() == 2) {
56 citizen.setVaccinationStatus("Fully Vaccinated");
57 } else {
58 citizen.setVaccinationStatus("Not Vaccinated");
59 }
60 // Handle the form submission and save the citizen
61 citizensRepository.save(citizen);
62
63 return "redirect:/displayCitizens";
64 }
65
66 @GetMapping("/editCitizenform")
67 public String editCitizen(@RequestParam("id") Long id, Model model) {
68 Optional<Citizens> citizenRepo = citizensRepository.findById(id);
69 Citizens citizen = citizenRepo.get();
70 model.addAttribute("citizen", citizen);
71
72 List<String> cityNames = vcRepo.findDistinctCityNames();
73 model.addAttribute("citynames", cityNames);
74 List<String> centerNames = vcRepo.findDistinctCenterNames();

Page 1
CitizensController.java Thursday, 22 June, 2023, 7:12 pm

75 model.addAttribute("centerNames", centerNames);
76
77 return "editCitizen";
78 }
79
80 @PostMapping("/updateCitizen")
81 public String updateCitizen(@ModelAttribute("citizen") Citizens updatedCitizen,
@RequestParam("id") Long citizenId,
82 @RequestParam("vaccinationCentersId") Long vaccinationCentersId) {
83 // Retrieve the existing citizen using the citizenId
84 Optional<Citizens> existingCitizenOptional = citizensRepository.findById
(citizenId);
85 Citizens existingCitizen = existingCitizenOptional.orElseThrow();
86
87 // Retrieve the VaccinationCenters entity using the vaccinationCentersId
88 Optional<VaccinationCenters> vaccinationCenterOptional = vcRepo.findById
(vaccinationCentersId);
89 VaccinationCenters vaccinationCenter = vaccinationCenterOptional.orElseThrow
();
90
91 // Update the existing citizen with the new values
92 existingCitizen.setcName(updatedCitizen.getcName());
93 existingCitizen.setNoOfDoses(updatedCitizen.getNoOfDoses());
94 existingCitizen.getVaccinationCenters().setName
(updatedCitizen.getVaccinationCenters().getName());
95 existingCitizen.getVaccinationCenters().setCity
(updatedCitizen.getVaccinationCenters().getCity());
96 // setting vaccination status
97 if (existingCitizen.getNoOfDoses() == 2) {
98 existingCitizen.setVaccinationStatus("Fully Vaccinated");
99 } else {
100 existingCitizen.setVaccinationStatus("Not Vaccinated");
101 }
102 // Set the updated VaccinationCenters entity
103 existingCitizen.setVaccinationCenters(vaccinationCenter);
104
105 // Save the updated citizen
106 citizensRepository.save(existingCitizen);
107
108 return "redirect:/displayCitizens";
109 }
110
111 @GetMapping("/viewCitizenInfo")
112 public String viewCitizenInfo(@RequestParam("id") Long id, Model model) {
113 Optional<Citizens> citizenOpt = citizensRepository.findById(id);
114 Citizens citizen = citizenOpt.get();
115 model.addAttribute("citizen", citizen);
116 return "viewCitizen";
117
118 }
119
120 @GetMapping("/deleteCitizen")
121 public String deleteCitizen(@RequestParam("id") Long id) {
122 citizensRepository.deleteById(id);
123 return "redirect:/displayCitizens";
124 }
125
126 }
127

Page 2
LogoutController.java Thursday, 22 June, 2023, 7:14 pm

1 package com.vaccination.controllers;
2
3 import org.springframework.stereotype.Controller;
5
6 @Controller
7 public class LogoutController {
8
9 @GetMapping("/logout")
10 public String logout() {
11 return "logout";
12 }
13
14 }
15

Page 1
index.jsp Thursday, 22 June, 2023, 7:15 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <meta charset="UTF-8">
7 <title>Insert title here</title>
8
9 <style>
10 body {
11 display: flex;
12 justify-content: center;
13 align-items: center;
14 height: 100vh;
15 }
16
17 .loginContainer {
18 text-align: left;
19 border: 2px solid #800080;
20 padding: 10px;
21 }
22
23 .loginContainer form {
24 display: flex;
25 flex-direction: column;
26 align-items: flex-start;
27 }
28
29 .loginContainer input {
30 margin: 8px;
31 }
32 </style>
33 </head>
34 <body>
35 <div class="loginContainer">
36 <form action="login" method="post">
37 <h2>Login</h2>
38 Username: <input type="email" id="email" name="email">
39 Password: <input type="password" id="password" name="password">
40 <input type="submit" value="Login">
41 </form>
42 <form action="registerUser">
43 <input type="submit" value="Registration">
44 </form>
45 </div>
46 </body>
47 </html>

Page 1
registration.jsp Thursday, 22 June, 2023, 7:15 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <meta charset="UTF-8">
7 <title>Insert title here</title>
8
9 <style>
10 body {
11 display: flex;
12 justify-content: center;
13 align-items: center;
14 height: 100vh;
15 }
16
17 .registerContainer {
18 text-align: left;
19 border: 2px inset #800080;
20 padding: 10px;
21 }
22
23 .registerContainer form {
24 display: flex;
25 flex-direction: column;
26 align-items: center;
27 }
28 table tr th,td{
29 padding:10px;
30 }
31 .registerButton{
32 margin:10px;
33 }
34 </style>
35 </head>
36 <body>
37 <div class="registerContainer">
38 <h3>Admin Registration</h3>
39 <form action="registerUser" method="post">
40 <table border="1">
41 <tr>
42 <th>Registration</th>
43 </tr>
44 <tr>
45 <td>Name: <input type="text" name="name" id="name"></td>
46 </tr>
47 <tr>
48 <td>Email: <input type="email" name="email" id="email"></td>
49 </tr>
50 <tr>
51 <td>Password: <input type="password" name="password"
52 id="password"></td>
53 </tr>
54 </table>
55 <input type="submit" value="Register" class="registerButton">
56 </form>
57 </div>
58 </body>
59 </html>

Page 1
vaccinationcenter.jsp Thursday, 22 June, 2023, 7:15 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4
5 <!DOCTYPE html>
6 <html>
7 <head>
8 <meta charset="UTF-8">
9 <title>Insert title here</title>
10
11 <style>
12 table tr td {
13 padding: 10px;
14 text-align: center;
15 }
16 .buttons{
17 display:flex;
18 align-content: space-around;
19 }
20 .buttons input{
21 margin:5px;
22 }
23 .customBorder{
24 border: 2px outset #800080;
25 }
26 #table1width{
27 width:39.4%;
28 }
29 </style>
30
31 </head>
32 <body>
33 <table border="1" class="customBorder" id="table1width">
34 <tr>
35 <td><a href="displayCitizens">Citizens</a></td>
36 <td><a href="displayAllCenters">Vaccination Centers</a></td>
37 <td><a href="logout">Log Out</a></td>
38 <td>Welcome, admin</td>
39 </tr>
40 </table>
41 <h2>Centers</h2>
42 <table border="1" class="customBorder">
43 <tr>
44 <td>
45 <form action="AddVCform" method="get">
46 <input type="submit" value="Add New Center">
47 </form>
48 </td>
49 </tr>
50 <tr>
51 <th>ID</th>
52 <th>NAME</th>
53 <th>CITY</th>
54 <th>Action</th>
55 </tr>
56 <c:forEach var="vc" items="${vcs}">
57 <tr>
58 <td>${vc.id}</td>
59 <td>${vc.name}</td>

Page 1
vaccinationcenter.jsp Thursday, 22 June, 2023, 7:15 pm

60 <td>${vc.city}</td>
61 <td class="buttons">
62 <form action="editcenter" method="get">
63 <input type="hidden" name="id" value="${vc.id}"> <input
64 type="submit" value="Edit">
65 </form>
66 <form action="viewVaccinationCenterInfo">
67 <input type="hidden" name="id" value="${vc.id}">
68 <input type="submit" value="View">
69 </form>
70 <form action="deleteCenter" method="post">
71 <input type="hidden" name="id" value="${vc.id}"> <input
72 type="submit" value="Delete">
73 </form>
74
75 </td>
76 </tr>
77 </c:forEach>
78 </table>
79 </body>
80 </html>
81

Page 2
addVaccinationCenterForm.jsp Thursday, 22 June, 2023, 7:16 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <meta charset="UTF-8">
7 <title>Insert title here</title>
8 <style>
9 table{
10 width:30%;
11 }
12 table th, td{
13 padding: 10px;
14 }
15 .customBorder{
16 border: 2px inset #800080;
17 }
18 </style>
19 </head>
20 <body>
21 <form action="AddVC" method="post">
22 <table border="1" class="customBorder">
23 <tr>
24 <th>Add new Vaccination center</th>
25 </tr>
26 <tr>
27 <td>Center Name <input type="text" name="centerName"></td>
28 </tr>
29 <tr>
30 <td>Center City <select name="centerCity">
31 <option value="Warangal">warangal</option>
32 <option value="Hyderabad">Hyderabad</option>
33 <option value="Mulugu">Mulugu</option>
34 <option value="Mumbai">Mumbai</option>
35 <option value="Pune">Pune</option>
36 <option value="Bengaluru">Bengaluru</option>
37 </select>
38 </td>
39 </tr>
40 <tr><td><input type="submit" value="submit"></td></tr>
41 </table>
42 </form>
43 </body>
44 </html>

Page 1
editvaccinationcenter.jsp Thursday, 22 June, 2023, 7:16 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
4 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
5 <!DOCTYPE html>
6 <html>
7 <head>
8 <meta charset="UTF-8">
9 <title>Edit Vaccination Center</title>
10 <style>
11 table{
12 width:40%;
13 }
14 th, td {
15 padding: 20px;
16 }
17 td h3{
18 margin:0px;
19 padding:0px;
20 }
21 .customBorder{
22 border: 2px outset #800080;
23 }
24 </style>
25 </head>
26 <body>
27
28 <form:form action="editcenter" method="post" modelAttribute="vc">
29 <table border="1" class="customBorder">
30 <tr>
31 <td><h3>Center Information</h3></td>
32 </tr>
33 <tr>
34 <th>Edit ${vc.name}</th>
35 </tr>
36 <tr>
37 <td><form:label path="name">Center Name: </form:label> <form:input
38 path="name" /></td>
39 </tr>
40 <tr>
41 <td><form:label path="city">Center City:</form:label> <select
42 name="city">
43 <option value="Warangal" label="Warangal"
44 ${vc.city == 'Warangal' ? 'selected' : ''}></option>
45 <option value="Hyderabad" label="Hyderabad"
46 ${vc.city == 'Hyderabad' ? 'selected' : ''}></option>
47 <option value="Mulugu" label="Mulugu"
48 ${vc.city == 'Mulugu' ? 'selected' : ''}></option>
49 <option value="Mumbai" label="Mumbai"
50 ${vc.city == 'Mumbai' ? 'selected' : ''}></option>
51 <option value="Pune" label="pune"
52 ${vc.city == 'Pune' ? 'selected' : ''}></option>
53 <option value="Bengaluru" label="Bengaluru"
54 ${vc.city == 'Bengaluru' ? 'selected' : ''}></option>
55 </select></td>
56 </tr>
57 <tr>
58 <td><input type="submit" value="Update"></td>
59 </tr>

Page 1
editvaccinationcenter.jsp Thursday, 22 June, 2023, 7:16 pm

60 </table>
61 <input type="hidden" name="id" value="${vc.id}" />
62 </form:form>
63 </body>
64 </html>
65

Page 2
viewVaccinationCenter.jsp Thursday, 22 June, 2023, 7:16 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4 <!DOCTYPE html>
5 <html>
6 <head>
7 <meta charset="UTF-8">
8 <title>View VaccinationCenterInfo</title>
9 <style>
10 table tr td {
11 padding: 10px;
12 text-align: center;
13 }
14 .customBorder{
15 border: 2px outset #800080;
16 }
17 .container{
18 border: 1px ridge #800080;
19 padding:10px;
20 width:34%;
21 }
22 #table2Width{
23 width:40%;
24 }
25 </style>
26 </head>
27 <body>
28 <div class="container">
29 <table border="1" class="customBorder">
30 <tr>
31 <td><a href="displayCitizens">Citizens</a></td>
32 <td><a href="displayAllCenters">Vaccination Centers</a></td>
33 <td><a href="logout">Log Out</a></td>
34 <td>Welcome, admin</td>
35 </tr>
36 </table>
37 <h3>Center Information</h3>
38 <table border="1" class="customBorder" id="table2Width">
39 <tr>
40 <th colspan="2">Name</th>
41 </tr>
42 <tr>
43 <td colspan="2">${vaccinationcenter.name}</td>
44 </tr>
45 <tr>
46 <td>ID:</td>
47 <td>${vaccinationcenter.id}</td>
48 </tr>
49 <tr>
50 <td>City:</td>
51 <td>${vaccinationcenter.city}</td>
52 </tr>
53 </table>
54 <hr />
55 <h3>All Citizes Of this Center</h3>
56 <table border="1" class="customBorder">
57 <tr>
58 <th>ID</th>
59 <th>Name</th>

Page 1
viewVaccinationCenter.jsp Thursday, 22 June, 2023, 7:16 pm

60 <th>Action</th>
61 </tr>
62 <c:forEach var="cl" items="${citizensList}">
63 <tr>
64 <td>${cl.id}</td>
65 <td>${cl.cName}</td>
66 <td><a href="viewCitizenInfo?id=${cl.id}">View</a></td>
67 </tr>
68 </c:forEach>
69 </table>
70 </div>
71 </body>
72 </html>
73

Page 2
citizens.jsp Thursday, 22 June, 2023, 7:17 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
4
5 <!DOCTYPE html>
6 <html>
7 <head>
8 <meta charset="UTF-8">
9 <title>Insert title here</title>
10
11 <style>
12 table tr td {
13 padding: 10px;
14 text-align: center;
15 }
16 #table1Width{
17 width:40%;
18 }
19 .customBorder{
20 border: 2px inset #800080;
21 }
22 .buttons{
23 display:flex;
24 justify-content:space-between;
25 }
26 .buttons input{
27 margin:5px;
28 }
29 </style>
30
31 </head>
32 <body>
33 <table border="1" class="customBorder" id="table1Width">
34 <tr>
35 <td><a href="displayCitizens">Citizens</a></td>
36 <td><a href="displayAllCenters">Vaccination Centers</a></td>
37 <td><a href="logout">Log Out</a></td>
38 <td>Welcome, admin</td>
39 </tr>
40 </table>
41 <h3>Citizens</h3>
42 <table border="1" class="customBorder">
43 <tr>
44 <td>
45 <form action="addCitizen" method="get">
46 <input type="submit" value="Add New Citizen">
47 </form>
48 </td>
49 </tr>
50 <tr>
51 <th>ID</th>
52 <th>Name</th>
53 <th>City</th>
54 <th>No. of Doses</th>
55 <th>Vaccination Status</th>
56 <th>Vaccination Center</th>
57 <th>Action</th>
58 </tr>
59 <c:forEach var="citizen" items="${citizens}">

Page 1
citizens.jsp Thursday, 22 June, 2023, 7:17 pm

60 <tr>
61 <td>${citizen.id}</td>
62 <td>${citizen.cName}</td>
63 <td>${citizen.vaccinationCenters.city}</td>
64 <td>${citizen.noOfDoses}</td>
65 <td>${citizen.vaccinationStatus}</td>
66 <td>${citizen.vaccinationCenters.name}</td>
67 <td class="buttons">
68 <form action="editCitizenform" method="get">
69 <input type="hidden" name="id" value="${citizen.id}"> <input
70 type="submit" value="Edit">
71 </form>
72 <form action="viewCitizenInfo" method="get">
73 <input type="hidden" name="id" value="${citizen.id}"> <input
74 type="submit" value="View">
75 </form>
76 <form action="deleteCitizen" method="get">
77 <input type="hidden" name="id" value="${citizen.id}"> <input
78 type="submit" value="Delete">
79 </form>
80 </td>
81 </tr>
82 </c:forEach>
83 </table>
84 </body>
85 </html>
86

Page 2
addCitizenForm.jsp Thursday, 22 June, 2023, 7:17 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
4 <!DOCTYPE html>
5 <html>
6 <head>
7 <meta charset="UTF-8">
8 <title>Insert title here</title>
9 <style type="text/css">
10 table th, td {
11 padding: 8px;
12 }
13
14 table {
15 width: 30%;
16 }
17
18 .customBorder {
19 border: 2px inset #800080;
20 }
21 </style>
22 </head>
23 <body>
24 <form:form action="/addCitizen" method="post" modelAttribute="citizen">
25 <table border="1" class="customBorder">
26 <tr>
27 <th>Add new Citizen</th>
28 </tr>
29 <tr>
30 <td>Citizen Name <form:input path="cName" /></td>
31 </tr>
32 <tr>
33 <td><form:label path="vaccinationCenters.name">Center
Name:</form:label>
34 <form:select path="vaccinationCenters.name">
35 <form:options items="${centerNames}" />
36 </form:select></td>
37 </tr>
38 <tr>
39 <td><form:label path="vaccinationCenters.city">Citizen
City:</form:label>
40 <form:select path="vaccinationCenters.city">
41 <form:options items="${cityNames}" />
42 </form:select></td>
43 </tr>
44 <tr>
45 <td><input type="submit" value="Submit"></td>
46 </tr>
47 </table>
48 </form:form>
49 </body>
50 </html>
51

Page 1
editCitizen.jsp Thursday, 22 June, 2023, 7:17 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
4 <!DOCTYPE html>
5 <html>
6 <head>
7 <meta charset="UTF-8">
8 <title>Insert title here</title>
9 <style type="text/css">
10 table th, td {
11 padding: 10px;
12 }
13 table{
14 width:30%;
15 }
16 .customBorder{
17 border: 2px inset #800080;
18 }
19 </style>
20 </head>
21 <body>
22
23 <form:form modelAttribute="citizen" method="POST"
24 action="updateCitizen?id=${citizen.id}">
25 <input type="hidden" name="vaccinationCentersId"
value="${citizen.vaccinationCenters.id}">
26 <table border="1" class="customBorder">
27 <tr>
28 <th><h2>Edit Citizen</h2></th>
29 </tr>
30 <tr>
31 <td>Citizen Name: <form:input path="cName" /></td>
32 </tr>
33 <tr>
34 <td>Citizen City: <form:select path="vaccinationCenters.city">
35 <form:options items="${citynames}" />
36 </form:select></td>
37 </tr>
38 <tr>
39 <td>No. of Doses: <form:select path="noOfDoses">
40 <form:option value="0">None</form:option>
41 <form:option value="1">1</form:option>
42 <form:option value="2">2</form:option>
43 </form:select></td>
44 </tr>
45 <tr>
46 <td>Vaccination Center: <form:select
47 path="vaccinationCenters.name">
48 <form:options items="${centerNames}" />
49 </form:select></td>
50 </tr>
51 <tr>
52 <td colspan="1"><input type="submit" value="Update Citizen" /></td>
53 </tr>
54 </table>
55 </form:form>
56 </body>
57 </html>
58

Page 1
viewCitizen.jsp Thursday, 22 June, 2023, 7:17 pm

1 <%@ page language="java" contentType="text/html; charset=UTF-8"


2 pageEncoding="UTF-8"%>
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <meta charset="UTF-8">
7 <title>Insert title here</title>
8 <style>
9 table{
10 width:30%;
11 }
12 table th, td{
13 padding:10px;
14 text-align:center;
15 }
16 .customBorder{
17 border: 2px inset #800080;
18 }
19 </style>
20 </head>
21 <body>
22 <h2>Citizen Information</h2>
23 <table border="1" class="customBorder">
24 <tr>
25 <th colspan="2">${citizen.cName}</th>
26 </tr>
27 <tr>
28 <td>ID: </td><td>${citizen.id}</td>
29 </tr>
30 <tr>
31 <td>City: </td><td>${citizen.vaccinationCenters.city}</td>
32 </tr>
33 <tr>
34 <td>Number of Vaccines: </td><td>${citizen.noOfDoses}</td>
35 </tr>
36 <tr>
37 <td>Vaccination status: </td><td>${citizen.vaccinationStatus}</td>
38 </tr>
39 <tr>
40 <td>Allocated Vaccination Center: </td><td><a
href="viewVaccinationCenterInfo?
id=${citizen.vaccinationCenters.id}">${citizen.vaccinationCenters.name}</a></td>
41 </tr>
42 </table>
43 </body>
44 </html>

Page 1
logout.jsp Thursday, 22 June, 2023, 7:18 pm

1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Logged Out Successfully</title>
5 <style>
6 body {
7 font-family: Arial, sans-serif;
8 background-color: #f5f5f5;
9 display: flex;
10 justify-content: center;
11 align-items: center;
12 height: 100vh;
13 }
14
15 .container {
16 max-width: 400px;
17 padding: 20px;
18 background-color: #fff;
19 border: 2px inset #800080;
20 border-radius: 4px;
21 box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
22 text-align: center;
23 transition: box-shadow 0.3s ease;
24 }
25
26 .container:hover {
27 box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
28 }
29
30 h1 {
31 color: #333;
32 margin-bottom: 20px;
33 }
34
35 p {
36 color: #666;
37 margin-bottom: 10px;
38 }
39 </style>
40 </head>
41 <body>
42 <div class="container">
43 <h1>Logged Out Successfully</h1>
44 <p>Thank you for using our website.</p>
45 <p>Come back anytime!</p>
46 <p>If you have any questions, please contact our support. Cell:
47 9063605717</p>
48 </div>
49 </body>
50 </html>
51

Page 1

You might also like