├── build └── classes │ ├── Show.class │ └── app.class └── src └── main ├── java ├── Show.java └── app.java └── webapp ├── META-INF └── MANIFEST.MF ├── WEB-INF └── web.xml └── index.html /build/classes/Show.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Natanesh/Application_Form/1dcac304cbb4aef37ddf78e7f707dabeb2cf9206/build/classes/Show.class -------------------------------------------------------------------------------- /build/classes/app.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Natanesh/Application_Form/1dcac304cbb4aef37ddf78e7f707dabeb2cf9206/build/classes/app.class -------------------------------------------------------------------------------- /src/main/java/Show.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.sql.*; 3 | import jakarta.servlet.*; 4 | import jakarta.servlet.http.*; 5 | import jakarta.servlet.annotation.*; 6 | @WebServlet("/show") 7 | public class Show extends HttpServlet 8 | { 9 | String id,s; 10 | Connection con; 11 | Statement st; 12 | ResultSet rs; 13 | PrintWriter out; 14 | public void init() 15 | { 16 | try 17 | { 18 | Class.forName("com.mysql.cj.jdbc.Driver"); 19 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/app","root","nsnatanesh@2005S"); 20 | st=con.createStatement(); 21 | } 22 | catch(Exception e) 23 | { 24 | } 25 | } 26 | public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException 27 | { 28 | res.setContentType("text/html"); 29 | out=res.getWriter(); 30 | id=req.getParameter("id"); 31 | try 32 | { 33 | int a=0; 34 | rs=st.executeQuery("select * from app where id="+id+";"); 35 | while(rs.next()) 36 | { 37 | a=1; 38 | s=rs.getString(1); 39 | while(s.length()<4) 40 | { 41 | s="0"+s; 42 | } 43 | s="Id:"+s+""; 44 | s+="Name:"+rs.getString(2)+""; 45 | s+="Age:"+rs.getString(3)+""; 46 | s+="DOB:"+rs.getString(4)+""; 47 | s+="Blood Group:"+rs.getString(5)+""; 48 | s+="Address:"+rs.getString(6)+""; 49 | s+="Phone No:"+rs.getString(7)+""; 50 | s+="Email Id:"+rs.getString(8)+""; 51 | s+="Gender:"+rs.getString(9)+""; 52 | s+="Course:"+rs.getString(10)+""; 53 | } 54 | if(a==1) 55 | { 56 | out.println( 57 | ""+ 58 | ""+ 59 | "Application Form"+ 60 | ""+ 70 | ""+ 71 | ""+ 72 | "

Details

"+ 73 | ""+ 74 | s+ 75 | "
"+ 76 | ""+ 77 | "" 78 | ); 79 | } 80 | else 81 | { 82 | out.println( 83 | ""+ 84 | ""+ 85 | "Show"+ 86 | ""+ 98 | ""+ 99 | ""+ 100 | "

Invalid Id

"+ 101 | ""+ 102 | "" 103 | ); 104 | } 105 | } 106 | catch(Exception e) 107 | { 108 | out.println(""+e); 109 | } 110 | } 111 | public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException 112 | { 113 | doGet(req,res); 114 | } 115 | } -------------------------------------------------------------------------------- /src/main/java/app.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.sql.*; 3 | import jakarta.servlet.*; 4 | import jakarta.servlet.http.*; 5 | import jakarta.servlet.annotation.*; 6 | @WebServlet("/app") 7 | public class app extends HttpServlet 8 | { 9 | int x=0; 10 | String name,age,dob,bg,address,phno,email,gender,course="",button,s="",sl=""; 11 | Connection con; 12 | Statement st; 13 | ResultSet rs; 14 | PrintWriter out; 15 | public void init() 16 | { 17 | try 18 | { 19 | Class.forName("com.mysql.cj.jdbc.Driver"); 20 | con=DriverManager.getConnection("jdbc:mysql://localhost:3306/app","root","nsnatanesh@2005S"); 21 | st=con.createStatement(); 22 | } 23 | catch(Exception e) 24 | { 25 | } 26 | } 27 | public void doGet(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException 28 | { 29 | name=req.getParameter("name"); 30 | age=req.getParameter("age"); 31 | dob=req.getParameter("dob"); 32 | bg=req.getParameter("bg"); 33 | address=req.getParameter("address"); 34 | phno=req.getParameter("phno"); 35 | email=req.getParameter("email"); 36 | gender=req.getParameter("gender"); 37 | for(int i=1;i<=3;i++) 38 | { 39 | String c1=req.getParameter("c"+(""+i)); 40 | if(i==1 && !(course.equals(""))) 41 | { 42 | course=""; 43 | } 44 | if(c1!=null) 45 | { 46 | if(i!=3) 47 | { 48 | course+=c1+","; 49 | } 50 | else 51 | { 52 | course+=c1; 53 | } 54 | } 55 | } 56 | if(course.length()>0) 57 | { 58 | if(course.charAt(course.length()-1)==',') 59 | { 60 | course=course.substring(0,course.length()-1); 61 | } 62 | } 63 | button=req.getParameter("button"); 64 | res.setContentType("text/html"); 65 | out=res.getWriter(); 66 | if(button.equals("Add")) 67 | { 68 | String id="000"; 69 | try 70 | { 71 | rs=st.executeQuery("select id from app;"); 72 | while(rs.next()) 73 | { 74 | x=Integer.parseInt(rs.getString(1)); 75 | } 76 | x++; 77 | id+=x; 78 | while(id.length()>4) 79 | { 80 | id=id.substring(1,id.length()); 81 | } 82 | st.executeUpdate("insert into app values("+id+",'"+name+"',"+age+",'"+dob+"','"+bg+"','"+address+"',"+phno+",'"+email+"','"+gender+"','"+course+"');"); 83 | course=""; 84 | out.println( 85 | ""+ 86 | ""+ 87 | "Application Form" 88 | + ""+ 94 | ""+ 95 | ""+ 96 | "

Data Added Successfully!Thank You...

"+ 97 | "

Your Id is :"+id+"

"+ 98 | ""+ 99 | "" 100 | ); 101 | } 102 | catch(Exception e) 103 | { 104 | out.println(""+ 105 | ""+ 106 | "Application Form" 107 | + ""+ 119 | ""+ 120 | ""+ 121 | "

Please fill the form

"+ 122 | ""+ 123 | ""); 124 | } 125 | } 126 | else if(button.equals("Show")) 127 | { 128 | out.println(""+ 129 | ""+ 130 | "Application Form" 131 | + ""+ 167 | ""+ 168 | ""+ 169 | "
"+ 170 | ""+ 171 | "" 172 | + ""+ 174 | ""+ 175 | ""+ 176 | ""+ 179 | ""+ 180 | "

Enter user id

" 173 | + "
Id:"+ 177 | ""+ 178 | "
"+ 181 | "
"+ 182 | ""+ 183 | ""); 184 | } 185 | else if(button.equals("Show All")) 186 | { 187 | try 188 | { 189 | int j=0; 190 | rs=st.executeQuery("select * from app;"); 191 | while(rs.next()) 192 | { 193 | s+=rs.getString(1); 194 | while(s.length()<4) 195 | { 196 | s="0"+s; 197 | } 198 | s=""+s+""; 199 | s+=""+rs.getString(2)+""; 200 | s+=""+rs.getString(3)+""; 201 | s+=""+rs.getString(4)+""; 202 | s+=""+rs.getString(5)+""; 203 | s+=""+rs.getString(6)+""; 204 | s+=""+rs.getString(7)+""; 205 | s+=""+rs.getString(8)+""; 206 | s+=""+rs.getString(9)+""; 207 | s+=""+rs.getString(10)+""; 208 | sl+=""+s+""; 209 | s=""; 210 | j++; 211 | } 212 | if(j==0) 213 | { 214 | sl="No Record Found"; 215 | } 216 | out.println( 217 | ""+ 218 | ""+ 219 | "Application Form"+ 220 | "" 237 | + "" 238 | +""+ 239 | "

Details

"+ 240 | ""+ 241 | ""+ 242 | ""+ 243 | ""+ 244 | ""+ 245 | ""+ 246 | ""+ 247 | ""+ 248 | ""+ 249 | ""+ 250 | ""+ 251 | ""+ 252 | ""+ 253 | sl+ 254 | "
IdNameAgeDOBBlood GroupAddressPhone NoEmail IdGenderCourse
"+ 255 | ""+ 256 | ""); 257 | sl=""; 258 | } 259 | catch(Exception e) 260 | { 261 | } 262 | } 263 | else if(button.equals("Update")) 264 | { 265 | try 266 | { 267 | rs=st.executeQuery("select id from app where phno="+phno+";"); 268 | int z=0; 269 | String us,id=""; 270 | while(rs.next()) 271 | { 272 | id=rs.getString(1); 273 | z++; 274 | } 275 | if(z==0) 276 | { 277 | us="Invalid Phone Number"; 278 | } 279 | else 280 | { 281 | st.executeUpdate("update app set id="+id+",name='"+name+"',age="+age+",dob='"+dob+"',bg='"+bg+"',address='"+address+"',phno="+phno+",email='"+email+"',gender='"+gender+"',course='"+course+"' where id="+id+";"); 282 | us="Updated Successfully!..."; 283 | } 284 | course=""; 285 | out.println( 286 | ""+ 287 | ""+ 288 | "Application Form" 289 | + ""+ 301 | ""+ 302 | ""+ 303 | "

"+us+"

"+ 304 | ""+ 305 | "" 306 | ); 307 | } 308 | catch(Exception e) 309 | { 310 | out.println(""+ 311 | ""+ 312 | "Application Form" 313 | + ""+ 325 | ""+ 326 | ""+ 327 | "

Please fill the form

"+ 328 | ""+ 329 | ""); 330 | } 331 | } 332 | else if(button.equals("Delete")) 333 | { 334 | String ds,id=""; 335 | phno=req.getParameter("phno"); 336 | try 337 | { 338 | rs=st.executeQuery("select id from app where phno="+phno+";"); 339 | int z=0; 340 | while(rs.next()) 341 | { 342 | id=rs.getString(1); 343 | z=1; 344 | } 345 | if(z==0) 346 | { 347 | ds="Invalid Phone Number"; 348 | } 349 | else 350 | { 351 | st.executeUpdate("delete from app where id="+id+";"); 352 | ds="Deleted Successfully!..."; 353 | } 354 | out.println( 355 | ""+ 356 | ""+ 357 | "Application Form"+ 358 | ""+ 370 | ""+ 371 | ""+ 372 | "

"+ds+"

"+ 373 | ""+ 374 | "" 375 | ); 376 | } 377 | catch(Exception e) 378 | { 379 | out.println(""+ 380 | ""+ 381 | "Application Form" 382 | + ""+ 394 | ""+ 395 | ""+ 396 | "

Please Enter Phone Number

"+ 397 | ""+ 398 | ""); 399 | } 400 | } 401 | } 402 | public void doPost(HttpServletRequest req,HttpServletResponse res)throws IOException,ServletException 403 | { 404 | doGet(req,res); 405 | } 406 | } -------------------------------------------------------------------------------- /src/main/webapp/META-INF/MANIFEST.MF: -------------------------------------------------------------------------------- 1 | Manifest-Version: 1.0 2 | Class-Path: 3 | 4 | -------------------------------------------------------------------------------- /src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Application_Form 4 | 5 | index.html 6 | index.jsp 7 | index.htm 8 | default.html 9 | default.jsp 10 | default.htm 11 | 12 | -------------------------------------------------------------------------------- /src/main/webapp/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Application Form 7 | 37 | 38 | 39 |
40 | 41 |

Application

42 | 43 | 44 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 76 | 77 | 78 | 79 | 84 | 85 |
Name: 45 |
Age:
DOB:
Blood Group :
Address:
Phone No:
Email Id:
Gender: 73 | Male 74 | Female 75 |
Course: 80 | C 81 | Java 82 | Python 83 |
86 | 87 | 88 | 89 | 90 | 91 | 92 |
93 | 94 | --------------------------------------------------------------------------------