├── Database.PNG ├── EDMS ├── pom.xml ├── src │ └── main │ │ ├── java │ │ └── JavaFiles │ │ │ ├── AddAskHelp.java │ │ │ ├── AddContribution.java │ │ │ ├── AddLocation.java │ │ │ ├── AddPost.java │ │ │ ├── DataServlet.java │ │ │ ├── Login.java │ │ │ ├── MachineLearning.java │ │ │ ├── Pair.java │ │ │ ├── PredictWithModel.java │ │ │ ├── PrintCharacter.java │ │ │ ├── Registration.java │ │ │ ├── TrainModel.java │ │ │ ├── UpdateProfile.java │ │ │ └── divisions.java │ │ └── webapp │ │ ├── AddAskHelp.jsp │ │ ├── AddContribution.jsp │ │ ├── AddLocation.jsp │ │ ├── AddPost.jsp │ │ ├── CSS │ │ ├── Faq.css │ │ ├── Home.css │ │ ├── Location.css │ │ ├── LocationProfile.css │ │ ├── Post.css │ │ ├── Profile.css │ │ ├── Regi.css │ │ ├── Shelter_and_areas.css │ │ ├── Social.css │ │ └── login.css │ │ ├── Faq.jsp │ │ ├── Home.jsp │ │ ├── IMAGES │ │ ├── asif.jpg │ │ ├── badge-1.png │ │ ├── badge-2.png │ │ ├── badge-3.png │ │ ├── badge-4.png │ │ ├── badge-5.png │ │ ├── post1.jpg │ │ ├── post4.jpg │ │ ├── shakil.png │ │ └── unayes.jpeg │ │ ├── Location_Profile.jsp │ │ ├── Login.jsp │ │ ├── META-INF │ │ └── MANIFEST.MF │ │ ├── People_Profile.jsp │ │ ├── Profile.jsp │ │ ├── Registration.jsp │ │ ├── Shelter_and_Areas.jsp │ │ ├── Social.jsp │ │ ├── UpdateProfile.jsp │ │ ├── WEB-INF │ │ └── web.xml │ │ └── logout.jsp ├── target │ ├── classes │ │ └── JavaFiles │ │ │ ├── AddAskHelp.class │ │ │ ├── AddContribution.class │ │ │ ├── AddLocation.class │ │ │ ├── AddPost.class │ │ │ ├── DataServlet.class │ │ │ ├── Login.class │ │ │ ├── MachineLearning.class │ │ │ ├── Pair.class │ │ │ ├── PredictWithModel.class │ │ │ ├── PrintCharacter.class │ │ │ ├── Registration.class │ │ │ ├── TrainModel.class │ │ │ ├── UpdateProfile.class │ │ │ └── divisions.class │ └── m2e-wtp │ │ └── web-resources │ │ └── META-INF │ │ ├── MANIFEST.MF │ │ └── maven │ │ └── EDMS │ │ └── EDMS │ │ ├── pom.properties │ │ └── pom.xml └── trained_model.model ├── Home1.PNG ├── Home2.PNG ├── Home3.PNG ├── LICENSE ├── LocProfile1.PNG ├── LocProfile2.PNG ├── Profile.PNG ├── ProjectArchi.PNG ├── README.md ├── Shelter.PNG ├── Social.PNG ├── Therap Java Fest Certificate1.jpeg └── Therap Java Fest Finalist Certificate.jpg /Database.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ArfatulAsif/emergency-disaster-management-system-java-servlet-project/0f4ed0fb6c5b23ddc58e441ad7e136efea61cd67/Database.PNG -------------------------------------------------------------------------------- /EDMS/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | EDMS 4 | EDMS 5 | 0.0.1-SNAPSHOT 6 | war 7 | 8 | 9 | 10 | 11 | 12 | org.apache.commons 13 | commons-lang3 14 | 3.12.0 15 | 16 | 17 | 18 | mysql 19 | mysql-connector-java 20 | 8.0.33 21 | 22 | 23 | 24 | org.jsoup 25 | jsoup 26 | 1.16.1 27 | 28 | 29 | 30 | javax.servlet 31 | servlet-api 32 | 2.5 33 | provided 34 | 35 | 36 | 37 | org.mindrot 38 | jbcrypt 39 | 0.4 40 | 41 | 42 | 43 | com.fasterxml.jackson.core 44 | jackson-databind 45 | 2.12.5 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | nz.ac.waikato.cms.weka 54 | weka-stable 55 | 3.8.0 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | maven-compiler-plugin 66 | 3.8.1 67 | 68 | 17 69 | 70 | 71 | 72 | maven-war-plugin 73 | 3.2.3 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/AddAskHelp.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import jakarta.servlet.http.HttpSession; 10 | import jakarta.servlet.http.Part; 11 | 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.sql.Connection; 15 | import java.sql.DriverManager; 16 | import java.sql.PreparedStatement; 17 | import java.sql.SQLException; 18 | import java.text.SimpleDateFormat; 19 | import java.util.Date; 20 | import java.util.Locale; 21 | 22 | @MultipartConfig 23 | @WebServlet(name="AddAskHelp",urlPatterns= {"/AddAskHelp"}) 24 | public class AddAskHelp extends HttpServlet { 25 | private static final long serialVersionUID = 1L; 26 | 27 | 28 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 29 | Connection con = null; 30 | HttpSession session=request.getSession(false); 31 | String loggedInUser = (String) session.getAttribute("loggedInUser"); 32 | //System.out.println(loggedInUser); 33 | String LocationUsername=request.getParameter("LocationUsername"); 34 | //System.out.println(LocationUsername); 35 | String Description = request.getParameter("Description"); 36 | //System.out.println(Description); 37 | String ams=request.getParameter("help-am"); 38 | //System.out.println(ams); 39 | int am=Integer.parseInt(ams); 40 | String afs=request.getParameter("help-af"); 41 | int af=Integer.parseInt(afs); 42 | String acs=request.getParameter("help-ac"); 43 | int ac=Integer.parseInt(acs); 44 | int tot=af+am+ac; 45 | 46 | try 47 | { 48 | Class.forName("com.mysql.cj.jdbc.Driver"); 49 | } 50 | catch(ClassNotFoundException e) 51 | { 52 | e.printStackTrace(); 53 | } 54 | try 55 | { 56 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 57 | } 58 | catch(SQLException e) 59 | { 60 | e.printStackTrace(); 61 | } 62 | 63 | Part part1=request.getPart("ImageName1"); 64 | Part part2=request.getPart("ImageName2"); 65 | String contentType1 = part1.getContentType(); 66 | String contentType2 = part2.getContentType(); 67 | if (!(contentType1 != null && (contentType1.startsWith("image/jpeg") || contentType1.startsWith("image/png") || contentType1.startsWith("image/gif") || contentType1.startsWith("image/jpg") || contentType1.startsWith("image/svg") || contentType1.startsWith("image/webp")|| contentType1.startsWith("image/JPEG") || contentType1.startsWith("image/PNG") || contentType1.startsWith("image/GIF") || contentType1.startsWith("image/JPG") || contentType1.startsWith("image/SVG") || contentType1.startsWith("image/WEBP")))) { 68 | request.setAttribute("message", "Give a proper image ( Photo 1)"); 69 | String goUrl="AddAskHelp.jsp?LocationUsernameFromLocationProfile="+LocationUsername; 70 | request.getRequestDispatcher(goUrl).forward(request, response); 71 | } 72 | else if (!(contentType2 != null && (contentType2.startsWith("image/jpeg") || contentType2.startsWith("image/png") || contentType2.startsWith("image/gif") || contentType2.startsWith("image/jpg") || contentType2.startsWith("image/svg") || contentType2.startsWith("image/webp")|| contentType2.startsWith("image/JPEG") || contentType2.startsWith("image/PNG") || contentType2.startsWith("image/GIF") || contentType2.startsWith("image/JPG") || contentType2.startsWith("image/SVG") || contentType2.startsWith("image/WEBP")))) { 73 | request.setAttribute("message", "Give a proper image ( Photo 2)"); 74 | String goUrl="AddAskHelp.jsp?LocationUsernameFromLocationProfile="+LocationUsername; 75 | request.getRequestDispatcher(goUrl).forward(request, response); 76 | } 77 | else { 78 | 79 | try { 80 | InputStream is1=part1.getInputStream(); 81 | InputStream is2=part2.getInputStream(); 82 | PreparedStatement ps=con.prepareStatement("insert into "+LocationUsername+"_askhelp(Description,Photo1,Photo2,LocationUsername,Total,Username,Date,Second)values(?,?,?,?,?,?,?,?)"); 83 | ps.setString(1,Description); 84 | ps.setBlob(2, is1); 85 | ps.setBlob(3,is2); 86 | ps.setString(4, LocationUsername); 87 | ps.setInt(5, tot); 88 | ps.setString(6, loggedInUser); 89 | Date currentDate = new Date(); 90 | SimpleDateFormat dateFormat = new SimpleDateFormat("h:mma dd MMM, yyyy", Locale.ENGLISH); 91 | String formattedDateTime = dateFormat.format(currentDate); 92 | ps.setString(7, formattedDateTime); 93 | Date date = dateFormat.parse(formattedDateTime); 94 | long secondsSinceEpoch = date.getTime() / 1000; 95 | ps.setLong(8, secondsSinceEpoch); 96 | ps.executeUpdate(); 97 | }catch(Exception e) { 98 | 99 | } 100 | } 101 | response.sendRedirect("Location_Profile.jsp?LocationUsernameFromShelterPage="+LocationUsername); 102 | } 103 | 104 | 105 | } 106 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/AddContribution.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import jakarta.servlet.http.HttpSession; 10 | import jakarta.servlet.http.Part; 11 | 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.sql.Connection; 15 | import java.sql.DriverManager; 16 | import java.sql.PreparedStatement; 17 | import java.sql.ResultSet; 18 | import java.sql.SQLException; 19 | import java.sql.Statement; 20 | import java.text.SimpleDateFormat; 21 | import java.util.Date; 22 | import java.util.Locale; 23 | 24 | @MultipartConfig 25 | @WebServlet(name="AddContribution",urlPatterns= {"/AddContribution"}) 26 | public class AddContribution extends HttpServlet { 27 | private static final long serialVersionUID = 1L; 28 | 29 | 30 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 31 | 32 | Connection con = null; 33 | HttpSession session=request.getSession(false); 34 | String loggedInUser = (String) session.getAttribute("loggedInUser"); 35 | 36 | String LocationUsername=request.getParameter("LocationUsername"); 37 | String Description = request.getParameter("help-des"); 38 | String tot1=request.getParameter("help-Count"); 39 | int tot=Integer.parseInt(tot1); 40 | 41 | try 42 | { 43 | Class.forName("com.mysql.cj.jdbc.Driver"); 44 | } 45 | catch(ClassNotFoundException e) 46 | { 47 | e.printStackTrace(); 48 | } 49 | try 50 | { 51 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 52 | } 53 | catch(SQLException e) 54 | { 55 | e.printStackTrace(); 56 | } 57 | 58 | Part part1=request.getPart("help-p1"); 59 | Part part2=request.getPart("help-p2"); 60 | String contentType1 = part1.getContentType(); 61 | String contentType2 = part2.getContentType(); 62 | if (!(contentType1 != null && (contentType1.startsWith("image/jpeg") || contentType1.startsWith("image/png") || contentType1.startsWith("image/gif") || contentType1.startsWith("image/jpg") || contentType1.startsWith("image/svg") || contentType1.startsWith("image/webp")|| contentType1.startsWith("image/JPEG") || contentType1.startsWith("image/PNG") || contentType1.startsWith("image/GIF") || contentType1.startsWith("image/JPG") || contentType1.startsWith("image/SVG") || contentType1.startsWith("image/WEBP")))) { 63 | request.setAttribute("message", "Give a proper image ( Photo 1)"); 64 | String goUrl="AddContribution.jsp?LocationUsernameFromLocationProfile="+LocationUsername; 65 | request.getRequestDispatcher(goUrl).forward(request, response); 66 | } 67 | else if (!(contentType2 != null && (contentType2.startsWith("image/jpeg") || contentType2.startsWith("image/png") || contentType2.startsWith("image/gif") || contentType2.startsWith("image/jpg") || contentType2.startsWith("image/svg") || contentType2.startsWith("image/webp")|| contentType2.startsWith("image/JPEG") || contentType2.startsWith("image/PNG") || contentType2.startsWith("image/GIF") || contentType2.startsWith("image/JPG") || contentType2.startsWith("image/SVG") || contentType2.startsWith("image/WEBP")))) { 68 | request.setAttribute("message", "Give a proper image ( Photo 2)"); 69 | String goUrl="AddContribution.jsp?LocationUsernameFromLocationProfile="+LocationUsername; 70 | request.getRequestDispatcher(goUrl).forward(request, response); 71 | } 72 | else { 73 | 74 | try { 75 | InputStream is1=part1.getInputStream(); 76 | InputStream is2=part2.getInputStream(); 77 | PreparedStatement ps=con.prepareStatement("insert into "+LocationUsername+"_contribution(Description,Photo1,Photo2,LocationUsername,Total,Username,Date,Second)values(?,?,?,?,?,?,?,?)"); 78 | ps.setString(1,Description); 79 | ps.setBlob(2, is1); 80 | ps.setBlob(3,is2); 81 | ps.setString(4, LocationUsername); 82 | ps.setInt(5, tot); 83 | ps.setString(6, loggedInUser); 84 | Date currentDate = new Date(); 85 | SimpleDateFormat dateFormat = new SimpleDateFormat("h:mma dd MMM, yyyy", Locale.ENGLISH); 86 | String formattedDateTime = dateFormat.format(currentDate); 87 | ps.setString(7, formattedDateTime); 88 | Date date = dateFormat.parse(formattedDateTime); 89 | long secondsSinceEpoch = date.getTime() / 1000; 90 | ps.setLong(8, secondsSinceEpoch); 91 | ps.executeUpdate(); 92 | }catch(Exception e) { 93 | 94 | } 95 | } 96 | response.sendRedirect("Location_Profile.jsp?LocationUsernameFromShelterPage="+LocationUsername); 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/AddLocation.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import jakarta.servlet.http.Part; 10 | import jakarta.servlet.http.HttpSession; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.io.PrintWriter; 14 | import java.sql.Connection; 15 | import java.sql.DriverManager; 16 | import java.sql.PreparedStatement; 17 | import java.sql.ResultSet; 18 | import java.sql.SQLException; 19 | import java.sql.Statement; 20 | import java.text.SimpleDateFormat; 21 | import java.util.Date; 22 | import java.util.Locale; 23 | /** 24 | * Servlet implementation class AddLocation 25 | */ 26 | @MultipartConfig 27 | @WebServlet(name="AddLocation",urlPatterns= {"/AddLocation"}) 28 | public class AddLocation extends HttpServlet { 29 | private static final long serialVersionUID = 1L; 30 | 31 | PrintWriter out; 32 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 33 | Connection con = null; 34 | HttpSession session=request.getSession(false); 35 | String loggedInUser = (String) session.getAttribute("loggedInUser"); 36 | if (loggedInUser == null) { 37 | String currentURL = request.getRequestURI(); 38 | session.setAttribute("redirectURL", currentURL); 39 | response.sendRedirect("Login.jsp"); 40 | return; 41 | } 42 | String LocationUser=loggedInUser+"_loc_"; 43 | try 44 | { 45 | Class.forName("com.mysql.cj.jdbc.Driver"); 46 | } 47 | catch(ClassNotFoundException e) 48 | { 49 | e.printStackTrace(); 50 | } 51 | try 52 | { 53 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 54 | } 55 | catch(SQLException e) 56 | { 57 | e.printStackTrace(); 58 | } 59 | String qq="SELECT COUNT(*) FROM "+loggedInUser+"_location"; 60 | Statement stmt; 61 | int count_loc=0; 62 | try { 63 | stmt=con.createStatement(); 64 | ResultSet rs=stmt.executeQuery(qq); 65 | while(rs.next()) { 66 | count_loc=rs.getInt(1); 67 | count_loc++; 68 | } 69 | 70 | } catch (SQLException e) { 71 | // TODO Auto-generated catch block 72 | e.printStackTrace(); 73 | } 74 | LocationUser+=count_loc; 75 | 76 | String Name = request.getParameter("loc-name"); 77 | String Type = request.getParameter("loc-type"); 78 | String Description = request.getParameter("loc-des"); 79 | String linki = request.getParameter("loc-link"); 80 | 81 | String check1="https://www.google.c"; 82 | String check2="https://maps.app.goo"; 83 | String LinkCheck=linki.substring(0,Math.min(linki.length(),20)); 84 | if(LinkCheck.equals(check1)||LinkCheck.equals(check2)) { 85 | 86 | } 87 | else { 88 | request.setAttribute("message", "Give proper link"); 89 | request.getRequestDispatcher("AddLocation.jsp").forward(request, response); 90 | } 91 | 92 | String cont=request.getParameter("loc-cont"); 93 | String ams=request.getParameter("loc-am"); 94 | int am=Integer.parseInt(ams); 95 | String afs=request.getParameter("loc-af"); 96 | int af=Integer.parseInt(afs); 97 | String acs=request.getParameter("loc-ac"); 98 | int ac=Integer.parseInt(acs); 99 | int tot=af+am+ac; 100 | Part part1=request.getPart("loc-p1"); 101 | Part part2=request.getPart("loc-p2"); 102 | String link=request.getParameter("loc-link"); 103 | Statement stmtm; 104 | String selectedUnion= request.getParameter("selectedUnion"); 105 | 106 | String query5 = "SELECT * FROM bangladesh where Unionn = '"+selectedUnion+"'"; 107 | 108 | String District = null; 109 | String Upazilla = null; 110 | String Union = selectedUnion; 111 | 112 | Statement stmt5; 113 | try 114 | { 115 | stmt5 = con.createStatement(); 116 | ResultSet rs1 = stmt5.executeQuery(query5); 117 | while(rs1.next()) 118 | { 119 | District = rs1.getString("District"); 120 | Upazilla = rs1.getString("Upazila"); 121 | } 122 | 123 | } 124 | catch(Exception e) 125 | { 126 | e.printStackTrace(); 127 | } 128 | 129 | 130 | String contentType1 = part1.getContentType(); 131 | String contentType2 = part2.getContentType(); 132 | if (!(contentType1 != null && (contentType1.startsWith("image/jpeg") || contentType1.startsWith("image/png") || contentType1.startsWith("image/gif") || contentType1.startsWith("image/jpg") || contentType1.startsWith("image/svg") || contentType1.startsWith("image/webp")|| contentType1.startsWith("image/JPEG") || contentType1.startsWith("image/PNG") || contentType1.startsWith("image/GIF") || contentType1.startsWith("image/JPG") || contentType1.startsWith("image/SVG") || contentType1.startsWith("image/WEBP")))) { 133 | request.setAttribute("message", "Give a proper image ( Photo 1)"); 134 | String goUrl="AddLocation.jsp"; 135 | request.getRequestDispatcher(goUrl).forward(request, response); 136 | } 137 | else if (!(contentType2 != null && (contentType2.startsWith("image/jpeg") || contentType2.startsWith("image/png") || contentType2.startsWith("image/gif") || contentType2.startsWith("image/jpg") || contentType2.startsWith("image/svg") || contentType2.startsWith("image/webp")|| contentType2.startsWith("image/JPEG") || contentType2.startsWith("image/PNG") || contentType2.startsWith("image/GIF") || contentType2.startsWith("image/JPG") || contentType2.startsWith("image/SVG") || contentType2.startsWith("image/WEBP")))) { 138 | request.setAttribute("message", "Give a proper image ( Photo 2)"); 139 | String goUrl="AddLocation.jsp"; 140 | request.getRequestDispatcher(goUrl).forward(request, response); 141 | } 142 | else { 143 | 144 | try { 145 | InputStream is1=part1.getInputStream(); 146 | InputStream is2=part2.getInputStream(); 147 | 148 | PreparedStatement ps=con.prepareStatement("insert into "+loggedInUser+"_post(Description,Photo1,Photo2,Location,Affected,Date,Second)values(?,?,?,?,?,?,?)"); 149 | ps.setString(1,Description); 150 | ps.setBlob(2, is1); 151 | ps.setBlob(3,is2); 152 | ps.setString(4, selectedUnion); 153 | ps.setInt(5, tot); 154 | Date currentDate = new Date(); 155 | SimpleDateFormat dateFormat = new SimpleDateFormat("h:mma dd MMM, yyyy", Locale.ENGLISH); 156 | String formattedDateTime = dateFormat.format(currentDate); 157 | ps.setString(6, formattedDateTime); 158 | Date date = dateFormat.parse(formattedDateTime); 159 | long secondsSinceEpoch = date.getTime() / 1000; 160 | ps.setLong(7, secondsSinceEpoch); 161 | ps.executeUpdate(); 162 | 163 | /**/ 164 | PreparedStatement ps1=con.prepareStatement("insert into "+loggedInUser+"_location(Name,Type,Description,Photo1,Photo2,Location,Location_URL,Affected_Male,Affected_Female,Affected_Children,Affected_Total,ContactNo,Activity,LocationUsername,Date,Second)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); 165 | is1=part1.getInputStream(); 166 | is2=part2.getInputStream(); 167 | ps1.setString(1,Name); 168 | ps1.setString(2,Type); 169 | ps1.setString(3,Description); 170 | ps1.setBlob(4, is1); 171 | ps1.setBlob(5,is2); 172 | ps1.setString(6, selectedUnion); 173 | ps1.setString(7,linki); 174 | ps1.setInt(8, am); 175 | ps1.setInt(9, af); 176 | ps1.setInt(10, ac); 177 | ps1.setInt(11, tot); 178 | ps1.setString(12, cont); 179 | ps1.setString(13, "Inactive"); 180 | ps1.setString(14,LocationUser); 181 | ps1.setString(15, formattedDateTime); 182 | ps1.setLong(16, secondsSinceEpoch); 183 | ps1.executeUpdate(); 184 | PreparedStatement ps11=con.prepareStatement("create table "+LocationUser+"_askhelp(LocationUsername text,Description text,Photo1 longblob,Photo2 longblob,Male int,Female int,Children int,Total int,Username text,Date text,Second bigint);"); 185 | ps11.executeUpdate(); 186 | PreparedStatement ps22=con.prepareStatement("create table "+LocationUser+"_contribution(LocationUsername text,Description text,Photo1 longblob,Photo2 longblob,Total int,Username text,Date text,Second bigint);"); 187 | ps22.executeUpdate(); 188 | /**/ 189 | PreparedStatement ps3=con.prepareStatement("insert into location_added(LocationUsername,Name,Type,Activity,Second,Priority,TotalPriority , District , Upazilla , Unionn,Link,Photo1,Photo2,ContactNo,Description,Male,Female,Children,Total)values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); 190 | ps3.setString(1,LocationUser); 191 | ps3.setString(2,Name); 192 | ps3.setString(3,Type); 193 | is1=part1.getInputStream(); 194 | is2=part2.getInputStream(); 195 | 196 | ps3.setString(4, "Inactive"); 197 | ps3.setLong(5, secondsSinceEpoch); 198 | ps3.setFloat(6, 0); 199 | ps3.setFloat(7, 0); 200 | ps3.setString(8, District); 201 | ps3.setString(9, Upazilla); 202 | ps3.setString(10, Union); 203 | ps3.setString(11, link); 204 | ps3.setBlob(12,is1); 205 | ps3.setBlob(13,is2); 206 | ps3.setString(14, cont); 207 | ps3.setString(15,Description); 208 | ps3.setInt(16, am); 209 | ps3.setInt(17, af); 210 | ps3.setInt(18, ac); 211 | ps3.setInt(19, tot); 212 | ps3.executeUpdate(); 213 | 214 | /**/ 215 | 216 | PreparedStatement ps4=con.prepareStatement("insert into post_added "+"(Username,Photo1,Photo2,Description,District,Upazilla,Unionn,Affected,Date,Second,Name)values(?,?,?,?,?,?,?,?,?,?,?)"); 217 | 218 | is1=part1.getInputStream(); 219 | is2=part2.getInputStream(); 220 | ps4.setString(1,LocationUser); 221 | ps4.setBlob(2, is1); 222 | ps4.setBlob(3,is2); 223 | ps4.setString(4,Description); 224 | ps4.setString(5,District ); 225 | ps4.setString(6,Upazilla ); 226 | ps4.setString(7,Union ); 227 | ps4.setInt(8, tot); 228 | ps4.setString(9, formattedDateTime); 229 | ps4.setLong(10, secondsSinceEpoch); 230 | ps4.setString(11,Name ); 231 | ps4.executeUpdate(); 232 | response.sendRedirect("Profile.jsp"); 233 | 234 | }catch(Exception e) { 235 | 236 | } 237 | } 238 | } 239 | 240 | } 241 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/AddPost.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import jakarta.servlet.http.HttpSession; 10 | import jakarta.servlet.http.Part; 11 | 12 | import java.io.IOException; 13 | import java.io.InputStream; 14 | import java.io.PrintWriter; 15 | import java.sql.Connection; 16 | import java.sql.DriverManager; 17 | import java.sql.PreparedStatement; 18 | import java.sql.ResultSet; 19 | import java.sql.SQLException; 20 | import java.sql.Statement; 21 | import java.text.SimpleDateFormat; 22 | import java.util.Date; 23 | import java.util.Locale; 24 | 25 | 26 | @MultipartConfig 27 | @WebServlet(name="AddPost",urlPatterns= {"AddPost"}) 28 | public class AddPost extends HttpServlet { 29 | private static final long serialVersionUID = 1L; 30 | PrintWriter out; 31 | /** 32 | * @see HttpServlet#HttpServlet() 33 | */ 34 | 35 | 36 | 37 | 38 | 39 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 40 | // TODO Auto-generated method stub 41 | 42 | //System.out.println("Entered into Registration.java"); 43 | 44 | Connection con = null; 45 | 46 | try 47 | { 48 | Class.forName("com.mysql.cj.jdbc.Driver"); 49 | } 50 | catch(ClassNotFoundException e) 51 | { 52 | e.printStackTrace(); 53 | } 54 | try 55 | { 56 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 57 | } 58 | catch(SQLException e) 59 | { 60 | e.printStackTrace(); 61 | } 62 | 63 | HttpSession session=request.getSession(false); 64 | 65 | String Username = (String) session.getAttribute("loggedInUser"); 66 | if (Username == null) { 67 | String currentURL = request.getRequestURI(); 68 | session.setAttribute("redirectURL", currentURL); 69 | response.sendRedirect("Login.jsp"); 70 | } 71 | 72 | System.out.println("Printing from AddPost Servlet "+Username); 73 | 74 | 75 | String PostString = request.getParameter("PostString"); 76 | 77 | System.out.println(PostString); 78 | 79 | Statement stmtm; 80 | String selectedUnion= request.getParameter("selectedUnion"); 81 | 82 | 83 | String query1 = "SELECT * FROM bangladesh where Unionn = '"+selectedUnion+"'"; 84 | 85 | String District = null; 86 | String Upazilla = null; 87 | String Union = selectedUnion; 88 | 89 | Statement stmt1; 90 | try 91 | { 92 | stmt1 = con.createStatement(); 93 | ResultSet rs1 = stmt1.executeQuery(query1); 94 | while(rs1.next()) 95 | { 96 | District = rs1.getString("District"); 97 | Upazilla = rs1.getString("Upazila"); 98 | } 99 | 100 | } 101 | catch(Exception e) 102 | { 103 | e.printStackTrace(); 104 | } 105 | 106 | 107 | String Name=null; 108 | String queryn="SELECT * FROM registrationinfo where Username = '"+Username+"'"; 109 | Statement stmtn; 110 | try 111 | { 112 | stmtn = con.createStatement(); 113 | ResultSet rs1 = stmtn.executeQuery(queryn); 114 | while(rs1.next()) 115 | { 116 | Name=rs1.getString("Name"); 117 | } 118 | 119 | } 120 | catch(Exception e) 121 | { 122 | e.printStackTrace(); 123 | } 124 | //String ImageName = request.getParameter("ImageName"); 125 | 126 | 127 | 128 | 129 | response.setContentType("text/html;charset=UTF-8"); 130 | 131 | out=response.getWriter(); 132 | 133 | 134 | Part part1=request.getPart("ImageName1"); 135 | Part part2=request.getPart("ImageName2"); 136 | 137 | String contentType1 = part1.getContentType(); 138 | String contentType2 = part2.getContentType(); 139 | if (!(contentType1 != null && (contentType1.startsWith("image/jpeg") || contentType1.startsWith("image/png") || contentType1.startsWith("image/gif") || contentType1.startsWith("image/jpg") || contentType1.startsWith("image/svg") || contentType1.startsWith("image/webp")|| contentType1.startsWith("image/JPEG") || contentType1.startsWith("image/PNG") || contentType1.startsWith("image/GIF") || contentType1.startsWith("image/JPG") || contentType1.startsWith("image/SVG") || contentType1.startsWith("image/WEBP")))) { 140 | request.setAttribute("message", "Give a proper image ( Photo 1)"); 141 | String goUrl="AddPost.jsp"; 142 | request.getRequestDispatcher(goUrl).forward(request, response); 143 | } 144 | else if (!(contentType2 != null && (contentType2.startsWith("image/jpeg") || contentType2.startsWith("image/png") || contentType2.startsWith("image/gif") || contentType2.startsWith("image/jpg") || contentType2.startsWith("image/svg") || contentType2.startsWith("image/webp")|| contentType2.startsWith("image/JPEG") || contentType2.startsWith("image/PNG") || contentType2.startsWith("image/GIF") || contentType2.startsWith("image/JPG") || contentType2.startsWith("image/SVG") || contentType2.startsWith("image/WEBP")))) { 145 | request.setAttribute("message", "Give a proper image ( Photo 2)"); 146 | String goUrl="AddPost.jsp"; 147 | request.getRequestDispatcher(goUrl).forward(request, response); 148 | } 149 | else { 150 | 151 | if(part1!=null && part2!=null) { 152 | try { 153 | PreparedStatement ps=con.prepareStatement("insert into "+Username+"_post"+"(Description,Photo1,Photo2,Location,Affected,Date,Second)values(?,?,?,?,?,?,?)"); 154 | 155 | InputStream is1=part1.getInputStream(); 156 | InputStream is2=part2.getInputStream(); 157 | 158 | ps.setString(1,PostString); 159 | ps.setBlob(2, is1); 160 | ps.setBlob(3,is2); 161 | ps.setString(4, selectedUnion); 162 | ps.setInt(5, -1); 163 | Date currentDate = new Date(); 164 | SimpleDateFormat dateFormat = new SimpleDateFormat("h:mma dd MMM, yyyy", Locale.ENGLISH); 165 | String formattedDateTime = dateFormat.format(currentDate); 166 | ps.setString(6, formattedDateTime); 167 | Date date = dateFormat.parse(formattedDateTime); 168 | long secondsSinceEpoch = date.getTime() / 1000; 169 | ps.setLong(7, secondsSinceEpoch); 170 | int res=0; 171 | res=ps.executeUpdate(); 172 | 173 | PreparedStatement ps1=con.prepareStatement("insert into post_added "+"(Username,Photo1,Photo2,Description,District,Upazilla,Unionn,Affected,Date,Second,Name)values(?,?,?,?,?,?,?,?,?,?,?)"); 174 | 175 | is1=part1.getInputStream(); 176 | is2=part2.getInputStream(); 177 | ps1.setString(1,Username); 178 | ps1.setBlob(2, is1); 179 | ps1.setBlob(3,is2); 180 | ps1.setString(4,PostString ); 181 | ps1.setString(5,District ); 182 | ps1.setString(6,Upazilla ); 183 | ps1.setString(7,Union ); 184 | ps1.setInt(8, -1); 185 | ps1.setString(9, formattedDateTime); 186 | ps1.setLong(10, secondsSinceEpoch); 187 | ps1.setString(11,Name); 188 | ps1.executeUpdate(); 189 | 190 | }catch(Exception e) { 191 | System.out.println("Add image a dhora"); 192 | e.printStackTrace(); 193 | } 194 | 195 | } 196 | else 197 | { 198 | System.out.println("Photot somosssa"); 199 | } 200 | } 201 | response.sendRedirect("Profile.jsp"); 202 | } 203 | 204 | 205 | 206 | 207 | } 208 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/DataServlet.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.WebServlet; 5 | import jakarta.servlet.http.HttpServlet; 6 | import jakarta.servlet.http.HttpServletRequest; 7 | import jakarta.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | import java.sql.Connection; 10 | import java.sql.DriverManager; 11 | import java.sql.PreparedStatement; 12 | import java.sql.ResultSet; 13 | import java.sql.SQLException; 14 | import java.sql.Statement; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import com.fasterxml.jackson.databind.ObjectMapper; 19 | @WebServlet("/api/data") 20 | public class DataServlet extends HttpServlet { 21 | private static final long serialVersionUID = 1L; 22 | 23 | 24 | public DataServlet() { 25 | super(); 26 | // TODO Auto-generated constructor stub 27 | } 28 | 29 | /** 30 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 31 | */ 32 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 33 | 34 | // Handle API request 35 | try { 36 | Connection connection = null; 37 | try 38 | { 39 | Class.forName("com.mysql.cj.jdbc.Driver"); 40 | } 41 | catch(ClassNotFoundException e) 42 | { 43 | e.printStackTrace(); 44 | } 45 | try 46 | { 47 | connection=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 48 | } 49 | catch(SQLException e) 50 | { 51 | e.printStackTrace(); 52 | } 53 | String query = "SELECT * FROM location_added order by TotalPriority desc"; 54 | 55 | Statement stmt; 56 | ArrayListVerified1=new ArrayList(); 57 | ArrayListName1=new ArrayList(); 58 | ArrayListType1=new ArrayList(); 59 | ArrayListActivity1=new ArrayList(); 60 | ArrayListDistrict1=new ArrayList(); 61 | ArrayListUpazilla1=new ArrayList(); 62 | ArrayListUnion1=new ArrayList(); 63 | ArrayListUsername1=new ArrayList(); 64 | try 65 | { 66 | stmt = connection.createStatement(); 67 | ResultSet rs = stmt.executeQuery(query); 68 | while(rs.next()) 69 | { 70 | String name = rs.getString("Name"); 71 | String type = rs.getString("Type"); 72 | String activ = rs.getString("Activity"); 73 | String LocUser = rs.getString("LocationUsername"); 74 | String dist = rs.getString("District"); 75 | String upa = rs.getString("Upazilla"); 76 | String uni = rs.getString("Unionn"); 77 | String user= rs.getString("LocationUsername"); 78 | 79 | 80 | String Verified = null; 81 | 82 | String query2 = "SELECT * FROM location_verfied where LocationUsername = '"+LocUser+"'"; 83 | try 84 | { 85 | Statement stmt2 = connection.createStatement(); 86 | 87 | ResultSet rs2 = stmt2.executeQuery(query2); 88 | 89 | while(rs2.next()) 90 | { 91 | Verified = rs2.getString("LocationUsername"); 92 | } 93 | 94 | } 95 | catch(Exception e) 96 | { 97 | 98 | } 99 | 100 | 101 | 102 | Verified1.add(Verified); 103 | Name1.add(name); 104 | Type1.add(type); 105 | Activity1.add(activ); 106 | District1.add(dist); 107 | Upazilla1.add(upa); 108 | Union1.add(uni); 109 | Username1.add(user); 110 | //System.out.println("none"+Activity1.size()); 111 | 112 | } 113 | 114 | 115 | } 116 | catch(Exception e) 117 | { 118 | 119 | } 120 | List> mergedList = new ArrayList<>(); 121 | mergedList.add(Verified1); 122 | mergedList.add(Name1); 123 | mergedList.add(Type1); 124 | mergedList.add(Activity1); 125 | mergedList.add(District1); 126 | mergedList.add(Upazilla1); 127 | mergedList.add(Union1); 128 | mergedList.add(Username1); 129 | // Convert the data to JSON 130 | ObjectMapper objectMapper = new ObjectMapper(); 131 | try { 132 | String json = objectMapper.writeValueAsString(mergedList); 133 | 134 | response.setContentType("application/json"); 135 | response.setCharacterEncoding("UTF-8"); 136 | response.getWriter().write(json); 137 | } catch (Exception e) { 138 | e.printStackTrace(); 139 | } 140 | 141 | 142 | } catch (Exception e) { 143 | e.printStackTrace(); 144 | response.setStatus(500); 145 | } 146 | 147 | } 148 | 149 | 150 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 151 | // TODO Auto-generated method stub 152 | doGet(request, response); 153 | } 154 | 155 | } 156 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/Login.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import jakarta.servlet.http.HttpSession; 10 | import java.util.*; 11 | import java.io.IOException; 12 | import java.io.InputStream; 13 | import java.sql.Connection; 14 | import java.sql.DriverManager; 15 | import java.sql.PreparedStatement; 16 | import java.sql.ResultSet; 17 | import java.sql.SQLException; 18 | import java.sql.Statement; 19 | import org.mindrot.jbcrypt.BCrypt; 20 | 21 | @MultipartConfig 22 | @WebServlet(name="Login",urlPatterns= {"/Login"}) 23 | public class Login extends HttpServlet { 24 | private static final long serialVersionUID = 1L; 25 | 26 | 27 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 28 | Connection con = null; 29 | 30 | try 31 | { 32 | Class.forName("com.mysql.cj.jdbc.Driver"); 33 | } 34 | catch(ClassNotFoundException e) 35 | { 36 | e.printStackTrace(); 37 | } 38 | try 39 | { 40 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 41 | } 42 | catch(SQLException e) 43 | { 44 | 45 | e.printStackTrace(); 46 | } 47 | 48 | String Username=request.getParameter("log_username"); 49 | String pass=request.getParameter("log_password"); 50 | 51 | // ------------------------------- verified update here ------------------------------------------- 52 | 53 | 54 | 55 | 56 | 57 | String queryv = "SELECT * FROM verified WHERE Username = '"+Username+"'"; 58 | Statement stmtv; 59 | String Verified = null; 60 | try 61 | { 62 | stmtv = con.createStatement(); 63 | ResultSet rs = stmtv.executeQuery(queryv); 64 | while(rs.next()) 65 | { 66 | Verified = rs.getString("Username"); 67 | 68 | } 69 | 70 | } 71 | catch(Exception e) 72 | { 73 | e.printStackTrace(); 74 | } 75 | 76 | 77 | 78 | 79 | if(Verified==null) 80 | { 81 | 82 | int count = 0; 83 | 84 | String query90 = "SELECT * FROM "+Username+"_location"; 85 | Statement stmt90; 86 | try 87 | { 88 | stmt90 = con.createStatement(); 89 | ResultSet rs = stmt90.executeQuery(query90); 90 | while(rs.next()) 91 | { 92 | 93 | 94 | String LLocUsername = rs.getString("LocationUsername"); 95 | 96 | 97 | String query901 = "SELECT COUNT(*) FROM "+LLocUsername+"_askhelp"; 98 | Statement stmt901; 99 | 100 | try 101 | { 102 | stmt901 = con.createStatement(); 103 | ResultSet rs1 = stmt901.executeQuery(query901); 104 | while(rs1.next()) 105 | { 106 | 107 | count = count + rs1.getInt(1); 108 | 109 | } 110 | 111 | } 112 | catch(Exception e) 113 | { 114 | e.printStackTrace(); 115 | } 116 | 117 | } 118 | 119 | } 120 | catch(Exception e) 121 | { 122 | e.printStackTrace(); 123 | } 124 | 125 | 126 | if(count>=20) 127 | { 128 | 129 | try 130 | { 131 | PreparedStatement ps=con.prepareStatement("insert into verified(Username)values(?)"); 132 | 133 | ps.setString(1, Username); 134 | ps.executeUpdate(); 135 | } 136 | catch(Exception e) 137 | { 138 | 139 | } 140 | 141 | 142 | } 143 | 144 | } 145 | 146 | 147 | Statement stmtm; 148 | 149 | HttpSession session=request.getSession(); 150 | try { 151 | stmtm=con.createStatement(); 152 | ResultSet rss=stmtm.executeQuery("select * from registrationinfo where Username ='"+Username+"'"); 153 | String password=null; 154 | 155 | 156 | while(rss.next()) { 157 | password=rss.getString("Password"); 158 | if (BCrypt.checkpw(pass, password)) { 159 | password=pass; 160 | System.out.println("Password is correct."); 161 | } 162 | else { 163 | request.setAttribute("message", "Username or Password Doesn't Match"); 164 | request.getRequestDispatcher("Login.jsp").forward(request, response); 165 | } 166 | 167 | } 168 | 169 | 170 | if(password==null) { 171 | 172 | request.setAttribute("message", "Username or Password Doesn't Match"); 173 | request.getRequestDispatcher("Login.jsp").forward(request, response); 174 | } 175 | else if(password.equals(pass)) { 176 | 177 | session.setAttribute("loggedInUser", Username); 178 | 179 | String redirectURL = (String) session.getAttribute("redirectURL"); 180 | if (redirectURL != null) { 181 | 182 | 183 | session.removeAttribute("redirectURL"); 184 | response.sendRedirect(redirectURL); 185 | } else { 186 | response.sendRedirect("Home.jsp"); 187 | } 188 | } 189 | else { 190 | 191 | request.setAttribute("message", "Username or Password Doesn't Match"); 192 | request.getRequestDispatcher("Login.jsp").forward(request, response); 193 | } 194 | }catch(Exception e) { 195 | 196 | } 197 | 198 | } 199 | 200 | } -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/MachineLearning.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.WebServlet; 5 | import jakarta.servlet.http.HttpServlet; 6 | import jakarta.servlet.http.HttpServletRequest; 7 | import jakarta.servlet.http.HttpServletResponse; 8 | import java.io.IOException; 9 | import java.sql.Connection; 10 | import java.sql.DriverManager; 11 | import java.sql.ResultSet; 12 | import java.sql.SQLException; 13 | import java.sql.Statement; 14 | import java.util.*; 15 | import java.text.ParseException; 16 | import java.text.SimpleDateFormat; 17 | import java.util.Locale; 18 | import java.util.Date; 19 | 20 | import jakarta.servlet.ServletException; 21 | import jakarta.servlet.annotation.MultipartConfig; 22 | import jakarta.servlet.annotation.WebServlet; 23 | import jakarta.servlet.http.HttpServlet; 24 | import jakarta.servlet.http.HttpServletRequest; 25 | import jakarta.servlet.http.HttpServletResponse; 26 | import jakarta.servlet.http.HttpSession; 27 | import jakarta.servlet.http.Part; 28 | 29 | import java.io.IOException; 30 | import java.io.InputStream; 31 | import java.io.PrintWriter; 32 | import java.sql.Connection; 33 | import java.sql.DriverManager; 34 | import java.sql.PreparedStatement; 35 | import java.sql.ResultSet; 36 | import java.sql.SQLException; 37 | import java.sql.Statement; 38 | import java.text.SimpleDateFormat; 39 | import java.util.Date; 40 | import java.util.Locale; 41 | 42 | 43 | /** 44 | * Servlet implementation class MachineLearning 45 | */ 46 | public class MachineLearning extends HttpServlet { 47 | private static final long serialVersionUID = 1L; 48 | 49 | /** 50 | * @see HttpServlet#HttpServlet() 51 | */ 52 | public MachineLearning() { 53 | super(); 54 | // TODO Auto-generated constructor stub 55 | } 56 | 57 | /** 58 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 59 | */ 60 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 61 | // TODO Auto-generated method stub 62 | response.getWriter().append("Served at: ").append(request.getContextPath()); 63 | } 64 | 65 | /** 66 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 67 | */ 68 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 69 | // TODO Auto-generated method stub 70 | 71 | 72 | Connection con = null; 73 | 74 | try 75 | { 76 | Class.forName("com.mysql.cj.jdbc.Driver"); 77 | } 78 | catch(ClassNotFoundException e) 79 | { 80 | e.printStackTrace(); 81 | } 82 | try 83 | { 84 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 85 | } 86 | catch(SQLException e) 87 | { 88 | e.printStackTrace(); 89 | } 90 | 91 | 92 | ArrayList LocationUsername = new ArrayList(); 93 | ArrayList District = new ArrayList(); 94 | ArrayList Second = new ArrayList(); 95 | 96 | String queryU="select * from location_added"; 97 | Statement stmt0; 98 | try{ 99 | 100 | stmt0 = con.createStatement(); 101 | ResultSet rs0 = stmt0.executeQuery(queryU); 102 | while(rs0.next()){ 103 | String Username = rs0.getString("LocationUsername"); 104 | String DD = rs0.getString("District"); 105 | 106 | Long sec = rs0.getLong("Second"); 107 | 108 | District.add(DD); 109 | LocationUsername.add(Username); 110 | Second.add(sec); 111 | 112 | } 113 | }catch(Exception e){ 114 | 115 | } 116 | 117 | Date currentDate = new Date(); 118 | SimpleDateFormat dateFormat = new SimpleDateFormat("h:mma dd MMM, yyyy", Locale.ENGLISH); 119 | String formattedDateTime = dateFormat.format(currentDate); 120 | Date date; 121 | long secondsSinceEpoch=0; 122 | try { 123 | date = dateFormat.parse(formattedDateTime); 124 | secondsSinceEpoch = date.getTime() / 1000; 125 | 126 | } catch (ParseException e) { 127 | 128 | e.printStackTrace(); 129 | } 130 | 131 | int contribution = 0; 132 | int askhelp = 0; 133 | 134 | for(int i=0;i= "+yy+" AND second <= "+xx; 158 | Statement stmt12; 159 | try{ 160 | 161 | stmt12 = con.createStatement(); 162 | ResultSet rs12 = stmt12.executeQuery(query123); 163 | while(rs12.next()){ 164 | contribution = rs12.getInt(1); 165 | 166 | } 167 | }catch(Exception e){ 168 | 169 | } 170 | 171 | 172 | String query12311 = "SELECT COUNT(*) FROM " + LocationUsername.get(i) + "_askhelp WHERE second >= "+yy+" AND second <= "+xx; 173 | Statement stmt1211; 174 | try{ 175 | 176 | stmt1211 = con.createStatement(); 177 | ResultSet rs12 = stmt1211.executeQuery(query1231); 178 | while(rs12.next()){ 179 | askhelp = rs12.getInt(1); 180 | 181 | } 182 | }catch(Exception e){ 183 | 184 | } 185 | 186 | 187 | 188 | 189 | 190 | String Username=""; 191 | 192 | for(int j=0;j5) 228 | { 229 | 230 | try { 231 | // Establish a database connection 232 | 233 | 234 | // Define the SQL query with placeholders 235 | String sql = "UPDATE location_verified SET LocationUsername = ?"; 236 | 237 | // Create a prepared statement 238 | PreparedStatement preparedStatement = con.prepareStatement(sql); 239 | 240 | // Set the new total_priority, new priority, and condition values as parameters 241 | 242 | preparedStatement.setString(1,LocationUsername.get(i)); 243 | 244 | 245 | // Execute the update 246 | int rowsUpdated = preparedStatement.executeUpdate(); 247 | System.out.println("Rows updated: " + rowsUpdated); 248 | 249 | // Close the resources 250 | preparedStatement.close(); 251 | 252 | } catch (SQLException e) { 253 | e.printStackTrace(); 254 | } 255 | } 256 | 257 | 258 | if(MLvalue==1) 259 | { 260 | 261 | try { 262 | // Establish a database connection 263 | 264 | 265 | // Define the SQL query with placeholders 266 | String sql = "UPDATE location_added SET TotalPriority = ?, Activity = ? WHERE LocationUsername = ?"; 267 | 268 | // Create a prepared statement 269 | PreparedStatement preparedStatement = con.prepareStatement(sql); 270 | 271 | // Set the new total_priority, new priority, and condition values as parameters 272 | float x = (float)(Second.get(i)/1000000.00); 273 | preparedStatement.setFloat(1,x ); 274 | preparedStatement.setString(2 ,"Critical Help Needed"); 275 | preparedStatement.setString(3, LocationUsername.get(i)); 276 | 277 | // Execute the update 278 | int rowsUpdated = preparedStatement.executeUpdate(); 279 | System.out.println("Rows updated: " + rowsUpdated); 280 | 281 | // Close the resources 282 | preparedStatement.close(); 283 | 284 | } catch (SQLException e) { 285 | e.printStackTrace(); 286 | } 287 | 288 | 289 | 290 | 291 | try { 292 | // Establish a database connection 293 | 294 | 295 | // Define the SQL query with placeholders 296 | String sql = "UPDATE "+Username+"_location SET Activity = ? WHERE LocationUsername = ?"; 297 | 298 | // Create a prepared statement 299 | PreparedStatement preparedStatement = con.prepareStatement(sql); 300 | 301 | // Set the new total_priority, new priority, and condition values as parameters 302 | 303 | preparedStatement.setString(1 ,"Critical Help Needed"); 304 | preparedStatement.setString(2, LocationUsername.get(i)); 305 | 306 | // Execute the update 307 | int rowsUpdated = preparedStatement.executeUpdate(); 308 | System.out.println("Rows updated: " + rowsUpdated); 309 | 310 | // Close the resources 311 | preparedStatement.close(); 312 | 313 | } catch (SQLException e) { 314 | e.printStackTrace(); 315 | } 316 | 317 | } 318 | 319 | else 320 | { 321 | try { 322 | // Establish a database connection 323 | 324 | 325 | // Define the SQL query with placeholders 326 | String sql = "UPDATE location_added SET TotalPriority = ?, Activity = ? WHERE LocationUsername = ?"; 327 | 328 | // Create a prepared statement 329 | PreparedStatement preparedStatement = con.prepareStatement(sql); 330 | 331 | // Set the new total_priority, new priority, and condition values as parameters 332 | float x = (float)(Second.get(i)/10000000.00); 333 | preparedStatement.setFloat(1,x ); 334 | 335 | if(askhelp>0) 336 | { 337 | preparedStatement.setString(2 ,"Active"); 338 | } 339 | else 340 | { 341 | preparedStatement.setString(2 ,"Inactive"); 342 | } 343 | 344 | preparedStatement.setString(3, LocationUsername.get(i)); 345 | 346 | // Execute the update 347 | int rowsUpdated = preparedStatement.executeUpdate(); 348 | System.out.println("Rows updated: " + rowsUpdated); 349 | 350 | // Close the resources 351 | preparedStatement.close(); 352 | 353 | } catch (SQLException e) { 354 | e.printStackTrace(); 355 | } 356 | 357 | 358 | try { 359 | // Establish a database connection 360 | 361 | 362 | // Define the SQL query with placeholders 363 | String sql = "UPDATE "+Username+"_location SET Activity = ? WHERE LocationUsername = ?"; 364 | 365 | // Create a prepared statement 366 | PreparedStatement preparedStatement = con.prepareStatement(sql); 367 | 368 | // Set the new total_priority, new priority, and condition values as parameters 369 | 370 | if(askhelp>0) 371 | { 372 | preparedStatement.setString(1 ,"Active"); 373 | } 374 | else 375 | { 376 | preparedStatement.setString(1 ,"Inactive"); 377 | } 378 | 379 | preparedStatement.setString(2, LocationUsername.get(i)); 380 | 381 | // Execute the update 382 | int rowsUpdated = preparedStatement.executeUpdate(); 383 | System.out.println("Rows updated: " + rowsUpdated); 384 | 385 | // Close the resources 386 | preparedStatement.close(); 387 | 388 | } catch (SQLException e) { 389 | e.printStackTrace(); 390 | } 391 | 392 | 393 | } 394 | 395 | 396 | 397 | 398 | 399 | 400 | } 401 | 402 | response.sendRedirect("Profile.jsp"); 403 | 404 | 405 | 406 | } 407 | 408 | } 409 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/Pair.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | public class Pair 4 | { 5 | public double First; 6 | public double second; 7 | Pair(double a , double b) 8 | { 9 | First = a; 10 | second = b; 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/PredictWithModel.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import weka.classifiers.Classifier; 4 | import weka.core.Instances; 5 | import weka.core.SerializationHelper; 6 | import weka.core.DenseInstance; 7 | import weka.core.Attribute; 8 | 9 | import java.util.ArrayList; 10 | 11 | import org.jsoup.Jsoup; 12 | import org.jsoup.nodes.Document; 13 | import org.jsoup.nodes.Element; 14 | import org.jsoup.select.Elements; 15 | 16 | public class PredictWithModel { 17 | 18 | public int Predict(String District , int contribution , int askHelp) throws Exception { 19 | 20 | 21 | // Load the pre-trained model (replace "trained_model.model" with the actual model file) 22 | 23 | Classifier model = TrainModel.trainModel(); 24 | 25 | // Define the attributes (excluding the class attribute) 26 | ArrayList attributes = new ArrayList<>(); 27 | attributes.add(new Attribute("DangerLevel")); 28 | attributes.add(new Attribute("Day1")); 29 | attributes.add(new Attribute("Day2")); 30 | attributes.add(new Attribute("Day3")); 31 | attributes.add(new Attribute("Day4")); 32 | attributes.add(new Attribute("Day5")); 33 | attributes.add(new Attribute("Day6")); 34 | attributes.add(new Attribute("Day7")); 35 | attributes.add(new Attribute("ContributionCountInLast3Days")); 36 | attributes.add(new Attribute("AskForHelpInLast3Days")); 37 | 38 | // Create a new Instances object for prediction 39 | Instances newInstance = new Instances("PredictionData", attributes, 0); 40 | 41 | // Create a class attribute "CriticalHelpNeeded" (replace with the actual class values) 42 | ArrayList classValues = new ArrayList(); 43 | classValues.add("0"); // Not needed 44 | classValues.add("1"); // Critical help needed 45 | Attribute classAttribute = new Attribute("CriticalHelpNeeded", classValues); 46 | 47 | newInstance.insertAttributeAt(classAttribute, newInstance.numAttributes()); 48 | 49 | // Set class index to the newly added class attribute 50 | newInstance.setClassIndex(newInstance.numAttributes() - 1); 51 | 52 | // Create a new instance for prediction (replace with your data) 53 | 54 | 55 | 56 | String Sylhet[]=new String[10]; 57 | String Moulvibazar[]=new String[10]; 58 | Document doc = Jsoup.connect("http://www.ffwc.gov.bd/ffwc_charts/waterlevelfcast.php").get(); 59 | Element table = doc.select("table").get(0); 60 | Elements rows = table.select("tr"); 61 | 62 | for (int i = 3; i < rows.size(); i++) { 63 | Element row = rows.get(i); 64 | Elements td = row.getAllElements(); 65 | try { 66 | if(td.get(1).text().equals("Brahmaputra Basin")||td.get(1).text().equals("Ganges Basin")||td.get(1).text().equals("Meghna Basin")||td.get(1).text().equals("South Eastern Hill Basin")) { 67 | System.out.println(td.get(1).text()); 68 | System.out.println(); 69 | }else { 70 | if(td.get(2).text().equals("Sylhet")) { 71 | Sylhet[0]=td.get(3).text(); 72 | Sylhet[1]=td.get(4).text(); 73 | Sylhet[2]=td.get(5).text(); 74 | Sylhet[3]=td.get(6).text(); 75 | Sylhet[4]=td.get(7).text(); 76 | Sylhet[5]=td.get(8).text(); 77 | Sylhet[6]=td.get(9).text(); 78 | Sylhet[7]=td.get(10).text(); 79 | } 80 | if(td.get(2).text().equals("Moulvibazar")) { 81 | Moulvibazar[0]=td.get(3).text(); 82 | Moulvibazar[1]=td.get(4).text(); 83 | Moulvibazar[2]=td.get(5).text(); 84 | Moulvibazar[3]=td.get(6).text(); 85 | Moulvibazar[4]=td.get(7).text(); 86 | Moulvibazar[5]=td.get(8).text(); 87 | Moulvibazar[6]=td.get(9).text(); 88 | Moulvibazar[7]=td.get(10).text(); 89 | } 90 | //System.out.println("River Name: "+td.get(1).text()+" Station Name: "+td.get(2).text()+" Danger Level: "+td.get(3).text()+" Observe Level: "+td.get(4).text());System.out.println(); 91 | } 92 | }catch(Exception e) { 93 | System.out.print(""); 94 | } 95 | } 96 | 97 | 98 | double[] newValues = new double[10]; 99 | 100 | if(District == "Sylhet") 101 | { 102 | for(int i=0;i<8;i++) 103 | { 104 | newValues[i] = Double.parseDouble(Sylhet[i]); 105 | } 106 | } 107 | else 108 | { 109 | 110 | for(int i=0;i<8;i++) 111 | { 112 | newValues[i] = Double.parseDouble(Moulvibazar[i]); 113 | } 114 | } 115 | 116 | newValues[8] = contribution; 117 | newValues[9] = askHelp; 118 | 119 | 120 | 121 | 122 | 123 | DenseInstance instance = new DenseInstance(attributes.size() + 1); // +1 for the class attribute 124 | 125 | for (int i = 0; i < newValues.length; i++) { 126 | if (i == attributes.size()) { 127 | // Set class attribute 128 | instance.setValue(classAttribute, newValues[i]); 129 | } else { 130 | instance.setValue(attributes.get(i), newValues[i]); 131 | } 132 | } 133 | 134 | // Add the instance to the Instances object 135 | newInstance.add(instance); 136 | 137 | // Classify the new instance 138 | double predictedClass = model.classifyInstance(newInstance.firstInstance()); 139 | 140 | // Get the predicted class label 141 | String predictedDecision = newInstance.attribute(newInstance.numAttributes() - 1).value((int) predictedClass); 142 | System.out.println("Predicted Decision: " + predictedDecision); 143 | 144 | int val = Integer.parseInt(predictedDecision); 145 | 146 | return val; 147 | } 148 | } -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/PrintCharacter.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | public class PrintCharacter { 4 | 5 | public String Print_200_Characters(String a) 6 | { 7 | String temp=""; 8 | 9 | int min = 200; 10 | 11 | if(min>a.length()) 12 | { 13 | min = a.length(); 14 | } 15 | 16 | for(int i=0;i0) 113 | { 114 | 115 | request.setAttribute("message", "Username Already Exists"); 116 | request.getRequestDispatcher("Registration.jsp").forward(request, response); 117 | 118 | } 119 | else if(!password1.equals(password2)) 120 | { 121 | 122 | request.setAttribute("message", "Password and Re-Password doesn't match"); 123 | request.getRequestDispatcher("Registration.jsp").forward(request, response); 124 | 125 | } 126 | else { 127 | response.setContentType("text/html;charset=UTF-8"); 128 | out=response.getWriter(); 129 | int res=0; 130 | Part part=request.getPart("ImageName"); 131 | 132 | String contentType1 = part.getContentType(); 133 | if (!(contentType1 != null && (contentType1.startsWith("image/jpeg") || contentType1.startsWith("image/png") || contentType1.startsWith("image/gif") || contentType1.startsWith("image/jpg") || contentType1.startsWith("image/svg") || contentType1.startsWith("image/webp")|| contentType1.startsWith("image/JPEG") || contentType1.startsWith("image/PNG") || contentType1.startsWith("image/GIF") || contentType1.startsWith("image/JPG") || contentType1.startsWith("image/SVG") || contentType1.startsWith("image/WEBP")))) { 134 | request.setAttribute("message", "Give a proper image"); 135 | request.getRequestDispatcher("Registration.jsp").forward(request, response); 136 | } else { 137 | 138 | 139 | 140 | if(part!=null) { 141 | try { 142 | PreparedStatement ps=con.prepareStatement("insert into registrationinfo(Image,Name,Username,Password,Type,ContactNo,Email,Description,Location)values(?,?,?,?,?,?,?,?,?)"); 143 | 144 | InputStream is=part.getInputStream(); 145 | 146 | ps.setBlob(1, is); 147 | ps.setString(2, Name); 148 | ps.setString(3, Username); 149 | String hashedPassword = BCrypt.hashpw(password1, BCrypt.gensalt()); 150 | ps.setString(4, hashedPassword); 151 | ps.setString(5, TypeSelect); 152 | ps.setString(6, ContactNo); 153 | ps.setString(7, Email); 154 | ps.setString(8, Description); 155 | ps.setString(9, selectedUnion); 156 | 157 | res=ps.executeUpdate(); 158 | PreparedStatement ps1=con.prepareStatement("create table "+Username+"_post(Description text,Photo1 longblob,Photo2 longblob,Location text,Affected int,Date text,Second bigint);"); 159 | ps1.executeUpdate(); 160 | ps1=con.prepareStatement("create table "+Username+"_location(LocationUsername text,Name text,Type text,Description text,Photo1 longblob,Photo2 longblob,Location text,Location_URL text,Affected_Male int,Affected_Female int,Affected_Children int,Affected_Total int,ContactNo text,Activity text,Date text,Second bigint);"); 161 | ps1.executeUpdate(); 162 | 163 | if(res>0) { 164 | response.sendRedirect("Login.jsp"); 165 | } 166 | else { 167 | response.sendRedirect("Registration.jsp?message=Some+Error+Occured"); 168 | } 169 | }catch(SQLException e) { 170 | System.out.println("Add image a dhora"); 171 | e.printStackTrace(); 172 | } 173 | 174 | } 175 | } 176 | } 177 | } 178 | 179 | } 180 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/TrainModel.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import weka.classifiers.trees.J48; 4 | import weka.core.Attribute; 5 | import weka.core.Instances; 6 | import weka.core.SerializationHelper; 7 | import weka.core.DenseInstance; 8 | 9 | import java.util.ArrayList; 10 | 11 | 12 | public class TrainModel { 13 | public static J48 trainModel() throws Exception { 14 | // Create attribute information (names and types) 15 | ArrayList attributes = new ArrayList<>(); 16 | 17 | attributes.add(new Attribute("DangerLevel")); 18 | attributes.add(new Attribute("Day1")); 19 | attributes.add(new Attribute("Day2")); 20 | attributes.add(new Attribute("Day3")); 21 | attributes.add(new Attribute("Day4")); 22 | attributes.add(new Attribute("Day5")); 23 | attributes.add(new Attribute("Day6")); 24 | attributes.add(new Attribute("Day7")); 25 | attributes.add(new Attribute("ContributionCountInLast3Days")); 26 | attributes.add(new Attribute("AskForHelpInLast3Days")); 27 | 28 | // Create class attribute "CriticalHelpNeeded" 29 | ArrayList classValues = new ArrayList<>(); 30 | classValues.add("0"); // Not needed 31 | classValues.add("1"); // Critical help needed 32 | Attribute classAttribute = new Attribute("CriticalHelpNeeded", classValues); 33 | 34 | attributes.add(classAttribute); 35 | 36 | // Create dataset 37 | Instances dataset = new Instances("ReliefCenterData", attributes, 0); 38 | dataset.setClassIndex(attributes.size() - 1); // Set class attribute 39 | 40 | 41 | 42 | 43 | // Add data instances (replace with your data) 44 | String[] dataLines = { 45 | "10.80,7.28,6.98,6.77,6.67,6.77,6.97,7.19,2,2,0", 46 | "10.80,9.28,9.98,9.77,9.67,10.77,9.97,9.19,1,5,1", 47 | "10.80,7.28,6.98,6.77,6.67,6.77,6.97,7.19,3,7,1", 48 | "10.80,11.28,9.98,11.77,9.67,10.77,9.97,9.19,1,1,0", 49 | "10.80,10.28,11.98,11.77,9.67,10.77,9.97,9.19,2,4,1" 50 | }; 51 | 52 | for (String dataLine : dataLines) { 53 | String[] values = dataLine.split(","); 54 | double[] instanceValues = new double[attributes.size()]; 55 | 56 | for (int i = 0; i < values.length; i++) { 57 | if (i == attributes.size() - 1) { 58 | // Set class attribute 59 | instanceValues[i] = classAttribute.indexOfValue(values[i]); 60 | } else { 61 | instanceValues[i] = Double.parseDouble(values[i]); 62 | } 63 | } 64 | 65 | dataset.add(new DenseInstance(1.0, instanceValues)); 66 | } 67 | 68 | // Create and train a J48 decision tree classifier 69 | J48 tree = new J48(); 70 | tree.buildClassifier(dataset); 71 | 72 | // Save the trained model to a file 73 | 74 | 75 | System.out.println("Model trained and saved successfully."); 76 | return tree; 77 | 78 | } 79 | } -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/UpdateProfile.java: -------------------------------------------------------------------------------- 1 | package JavaFiles; 2 | 3 | import jakarta.servlet.ServletException; 4 | import jakarta.servlet.annotation.MultipartConfig; 5 | import jakarta.servlet.annotation.WebServlet; 6 | import jakarta.servlet.http.HttpServlet; 7 | import jakarta.servlet.http.HttpServletRequest; 8 | import jakarta.servlet.http.HttpServletResponse; 9 | import java.io.IOException; 10 | import java.sql.Connection; 11 | import java.sql.DriverManager; 12 | import java.sql.PreparedStatement; 13 | import java.sql.SQLException; 14 | import org.mindrot.jbcrypt.BCrypt; 15 | 16 | @MultipartConfig 17 | @WebServlet(name="UpdateProfile",urlPatterns= {"/UpdateProfile"}) 18 | public class UpdateProfile extends HttpServlet { 19 | private static final long serialVersionUID = 1L; 20 | 21 | 22 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 | System.out.println("aise"); 24 | Connection con = null; 25 | 26 | try 27 | { 28 | Class.forName("com.mysql.cj.jdbc.Driver"); 29 | } 30 | catch(ClassNotFoundException e) 31 | { 32 | e.printStackTrace(); 33 | } 34 | try 35 | { 36 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/edms" , "root",""); 37 | } 38 | catch(SQLException e) 39 | { 40 | 41 | e.printStackTrace(); 42 | } 43 | String Username=request.getParameter("Username"); 44 | String Name=request.getParameter("Name"); 45 | String Cont=request.getParameter("Cont"); 46 | String Password=""; 47 | Password=request.getParameter("Password"); 48 | if(Password.equals("")) { 49 | String sql="update registrationinfo set Name = ?, ContactNo = ? where Username=?"; 50 | try { 51 | System.out.println("aise"); 52 | System.out.println(Name); 53 | System.out.println(Cont); 54 | System.out.println(Username); 55 | PreparedStatement stmtp=con.prepareStatement(sql); 56 | stmtp.setString(1, Name); 57 | stmtp.setString(2, Cont); 58 | stmtp.setString(3, Username); 59 | int row= stmtp.executeUpdate(); 60 | System.out.println("update"+row); 61 | stmtp.close(); 62 | con.close(); 63 | } catch (SQLException e) { 64 | // TODO Auto-generated catch block 65 | e.printStackTrace(); 66 | } 67 | } 68 | else { 69 | String sql="update registrationinfo set Name=?, ContactNo=?, Password=? where Username=?"; 70 | try { 71 | PreparedStatement stmtp=con.prepareStatement(sql); 72 | stmtp.setString(1, Name); 73 | stmtp.setString(2, Cont); 74 | String hashedPassword = BCrypt.hashpw(Password, BCrypt.gensalt()); 75 | stmtp.setString(3, hashedPassword); 76 | stmtp.setString(4, Username); 77 | stmtp.executeUpdate(); 78 | stmtp.close(); 79 | con.close(); 80 | } catch (SQLException e) { 81 | // TODO Auto-generated catch block 82 | e.printStackTrace(); 83 | } 84 | } 85 | response.sendRedirect("Profile.jsp"); 86 | } 87 | 88 | } 89 | -------------------------------------------------------------------------------- /EDMS/src/main/java/JavaFiles/divisions.java: -------------------------------------------------------------------------------- 1 | 2 | package JavaFiles; 3 | 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | 7 | public class divisions { 8 | public Map divisionCoordinates = new HashMap<>(); 9 | 10 | public void make() 11 | { 12 | divisionCoordinates.put("Dhaka", new Pair(23.8103, 90.4125)); 13 | divisionCoordinates.put("Chittagong", new Pair(22.3475, 91.8123)); 14 | divisionCoordinates.put("Khulna", new Pair(22.8150, 89.5687)); 15 | divisionCoordinates.put("Rajshahi", new Pair(24.3740, 88.6011)); 16 | divisionCoordinates.put("Barisal", new Pair(22.7029, 90.3466)); 17 | divisionCoordinates.put("Rangpur", new Pair(25.7465, 89.2514)); 18 | divisionCoordinates.put("Mymensingh", new Pair(24.7466, 90.4077)); 19 | divisionCoordinates.put("Sylhet", new Pair(24.8897, 91.8759)); 20 | divisionCoordinates.put("Habiganj", new Pair(24.3864, 91.4182)); 21 | divisionCoordinates.put("Moulvibazar", new Pair(24.3065, 91.7296)); 22 | divisionCoordinates.put("Sunamganj", new Pair(25.0657, 91.4059)); 23 | divisionCoordinates.put("Faridpur", new Pair(23.5228, 89.8500)); 24 | divisionCoordinates.put("Gazipur", new Pair(24.0022, 90.4266)); 25 | divisionCoordinates.put("Gopalganj", new Pair(23.0022, 89.8268)); 26 | divisionCoordinates.put("Kishoreganj", new Pair(24.4333, 90.7750)); 27 | divisionCoordinates.put("Madaripur", new Pair(23.1690, 90.1985)); 28 | divisionCoordinates.put("Manikganj", new Pair(23.8583, 90.0391)); 29 | divisionCoordinates.put("Munshiganj", new Pair(23.5429, 90.5039)); 30 | divisionCoordinates.put("Narayanganj", new Pair(23.6062, 90.4996)); 31 | divisionCoordinates.put("Bandarban", new Pair(21.8310, 92.3686)); 32 | divisionCoordinates.put("Brahmanbaria", new Pair(23.9571, 91.1119)); 33 | divisionCoordinates.put("Chandpur", new Pair(23.2255, 90.6715)); 34 | divisionCoordinates.put("Comilla", new Pair(23.4160, 91.1588)); 35 | divisionCoordinates.put("Coxs Bazar", new Pair(21.4272, 92.0058)); 36 | divisionCoordinates.put("Feni", new Pair(23.0238, 91.3849)); 37 | divisionCoordinates.put("Khagrachari", new Pair(23.1126, 91.9630)); 38 | divisionCoordinates.put("Lakshmipur", new Pair(22.9420, 90.8402)); 39 | divisionCoordinates.put("Noakhali", new Pair(22.8432, 91.1082)); 40 | divisionCoordinates.put("Rangamati", new Pair(22.6511, 92.1822)); 41 | divisionCoordinates.put("Bogra", new Pair(24.8500, 89.3672)); 42 | divisionCoordinates.put("Joypurhat", new Pair(25.0968, 89.0319)); 43 | divisionCoordinates.put("Naogaon", new Pair(24.7936, 88.9318)); 44 | divisionCoordinates.put("Natore", new Pair(24.4206, 88.9762)); 45 | divisionCoordinates.put("Nawabganj", new Pair(24.5965, 88.2746)); 46 | divisionCoordinates.put("Pabna", new Pair(24.0128, 89.2380)); 47 | divisionCoordinates.put("Rajshahi", new Pair(24.3740, 88.6011)); 48 | divisionCoordinates.put("Sirajgonj", new Pair(24.4513, 89.7082)); 49 | divisionCoordinates.put("Bagerhat", new Pair(22.6584, 89.7850)); 50 | divisionCoordinates.put("Chuadanga", new Pair(23.6438, 88.8415)); 51 | divisionCoordinates.put("Jessore", new Pair(23.1667, 89.2089)); 52 | divisionCoordinates.put("Jhenaidah", new Pair(23.5441, 89.1524)); 53 | divisionCoordinates.put("Khulna", new Pair(22.8150, 89.5687)); 54 | divisionCoordinates.put("Kushtia", new Pair(23.9032, 89.1214)); 55 | divisionCoordinates.put("Magura", new Pair(23.4874, 89.4195)); 56 | divisionCoordinates.put("Meherpur", new Pair(23.7622, 88.6363)); 57 | divisionCoordinates.put("Narail", new Pair(23.1724, 89.5124)); 58 | divisionCoordinates.put("Satkhira", new Pair(22.7185, 89.0705)); 59 | divisionCoordinates.put("Barguna", new Pair(22.1500, 90.1122)); 60 | divisionCoordinates.put("Barisal", new Pair(22.7010, 90.3285)); 61 | divisionCoordinates.put("Bhola", new Pair(22.6859, 90.6480)); 62 | divisionCoordinates.put("Jhalokati", new Pair(22.6236, 90.1973)); 63 | divisionCoordinates.put("Patuakhali", new Pair(22.3595, 90.3314)); 64 | divisionCoordinates.put("Pirojpur", new Pair(22.5856, 89.9720)); 65 | divisionCoordinates.put("Jamalpur", new Pair(24.9312, 89.9440)); 66 | divisionCoordinates.put("Mymensingh", new Pair(24.7570, 90.4069)); 67 | divisionCoordinates.put("Netrokona", new Pair(24.8896, 90.7270)); 68 | divisionCoordinates.put("Sherpur", new Pair(25.0205, 90.0153)); 69 | } 70 | 71 | public static double haversineDistance(double lat1, double lon1, double lat2, double lon2) { 72 | // Convert degrees to radians 73 | lat1 = Math.toRadians(lat1); 74 | lon1 = Math.toRadians(lon1); 75 | lat2 = Math.toRadians(lat2); 76 | lon2 = Math.toRadians(lon2); 77 | 78 | // Haversine formula 79 | double dlat = lat2 - lat1; 80 | double dlon = lon2 - lon1; 81 | double a = Math.pow(Math.sin(dlat / 2), 2) + Math.cos(lat1) * Math.cos(lat2) * Math.pow(Math.sin(dlon / 2), 2); 82 | double c = 2 * Math.asin(Math.sqrt(a)); 83 | double r = 6371; // Earth's radius in kilometers 84 | double distance = c * r; 85 | 86 | return distance; 87 | } 88 | 89 | } 90 | -------------------------------------------------------------------------------- /EDMS/src/main/webapp/AddAskHelp.jsp: -------------------------------------------------------------------------------- 1 | <%@ page language="java" contentType="text/html; charset=ISO-8859-1" 2 | pageEncoding="ISO-8859-1"%> 3 | <%@page import="java.sql.*" %> 4 | 5 | 6 | 7 | 8 | 9 | Emergency Disaster Management System 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | <% 25 | 26 | String LocationUsername = request.getParameter("LocationUsernameFromLocationProfile"); 27 | %> 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | edms. 36 | 37 | 38 | 39 | 40 | Ask for Help 41 | 42 | 43 | 45 | 46 | 47 | 48 | Write Description 49 | 50 | 51 | 52 | 53 | 54 | Add 2 photos for visual confirmation : 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | Affected People Information : 63 | 64 | 65 | 66 | 67 | 68 | 69 | > 70 | 71 | 72 | ${message} 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 |
${message}