Implementation of Add, Delete and Search Employee From DataBase
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <center><h1><font face="Book Anitiqua">Admin Page</font></h1><br> <table> <tr><td><a href="[Link]"><font face="Calibri" size="+2">Add Employee</font></a></td></tr> <tr><td><a href="[Link]"><font face="Calibri" size="+2">Search Employee</font></a></td></tr> <tr><td><a href="[Link]"><font face="Calibri" size="+2">Delete Employee</font></a></td></tr> </table> </center> </body> </html>
Employee Data Entry Form
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <form method="post" action="Add_Emp.jsp"> <center><h1><font face="Book Anitiqua">Data Entry Page...!!!!</font></h1><br> <table border="1"> <tr><td><font face="Calibri" size="+2">Employee ID</font></td><td><input type="text" name="eid"></td></tr> <tr><td><font face="Calibri" size="+2">Employee First Name</font></td><td><input type="text" name="fname"></td></tr> <tr><td><font face="Calibri" size="+2">Employee Last Name</font></td><td><input type="text" name="lname"></td></tr> <tr><td><font face="Calibri" size="+2">Employee Department</font></td><td><input type="text" name="dept"></td></tr> <tr><td><font face="Calibri" size="+2">Employee Designation</font></td><td><input type="text" name="desig"></td></tr> <tr><td><font face="Calibri" size="+2">Employee Age</font></td><td><input type="text" name="age"></td></tr> <tr><td><font face="Calibri" size="+2">Employee Mobile No.</font></td><td><input type="text" name="phno"></td></tr> <tr><td><font face="Calibri" size="+2">Employee E-Mail</font></td><td><input type="text" name="email"></td></tr> <tr><td colspan="2"><center><input type="submit" value="Submit"></center></td> </table> </center> </form> </body> </html>
Add Employee Data To DataBase
<%@page import="[Link].*,[Link].*,[Link].*" contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% try{ [Link]("[Link]"); Connection con = [Link]("jdbc:odbc:MyDSN"); PreparedStatement pstmt = [Link]("insert into empdata values (?,?,?,?,?,?,?,?)"); [Link](1,[Link]("eid")); [Link](2,[Link]("fname")); [Link](3,[Link]("lname")); [Link](4,[Link]("dept")); [Link](5,[Link]("desig")); [Link](6,[Link]([Link]("age"))); [Link](7,[Link]("phno")); [Link](8,[Link]("email")); int a=[Link](); if(a==1) { %> <center><h1><font face="Book Anitiqua">Your information has been stored....!!!!</font> </h1></center> <% } else { %> <font color="red"><b>Not stored!</b></font>
<% } }catch(ClassNotFoundException e){ }catch(SQLException e){ }catch(Exception e){ } %> </body> </html>
Delete Record of Employee
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Delete Record</title> </head> <body><center><h1><font face="Book Anitiqua">Delete Record of Employee...!!!!</font></h1> <form method="get" action="Delete_Emp.jsp"> <font face="Calibri" size="+2">Enter Employee ID to Delete </font><input type="text" name="eid"> <input type="submit" name="Search"> </form></center> </body> </html>
<%@page import="[Link].*,[Link].*,[Link].*" contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% try{ [Link]("[Link]"); Connection con = [Link]("jdbc:odbc:MyDSN"); PreparedStatement pstmt = [Link]("delete from empdata where eid = ?"); [Link](1, [Link]("eid")); int a= [Link](); if(a==1) { %> <center><h1><font face="Book Anitiqua">Record has been deleted!!!</font></h1></center> <% } else { %> <center><h1><font face="Book Anitiqua">Record Not Found...!!!!</font></h1></center> <% } }catch(ClassNotFoundException e){ }catch(SQLException e){ }catch(Exception e){ } %> </body> </html>
Search Record From DataBase
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Search Record</title> </head> <body><center><h1><font face="Book Anitiqua">Search Record of Employee...!!!!</font></h1> <form method="get" action="Search_Emp.jsp"> <font face="Calibri" size="+2">Enter Employee ID to Search</font> <input type="text" name="eid"> <input type="submit" name="Search"> </form></center> </body> </html>
<%@page import="[Link].*,[Link].*,[Link].*" contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> </head> <body> <% try{ [Link]("[Link]"); Connection con = [Link]("jdbc:odbc:MyDSN"); PreparedStatement pstmt = [Link]("select * from empdata where eid = ?"); [Link](1, [Link]("eid")); ResultSet rst = [Link](); if([Link]()) { %> <center> <h1><font face="Book Anitiqua"> Employee Details...!!!!</font></h1>
<table border="1"> <tr><td><font face="Calibri" size="+2">ID</font></td><td><font face="Calibri" size="+2"><%=[Link]("eid")%></font></td></tr> <tr><td><font face="Calibri" size="+2">First Name</font></td><td><font face="Calibri" size="+2"><%=[Link]("fname")%></font></td></tr> <tr><td><font face="Calibri" size="+2">Last Name</font></td><td><font face="Calibri" size="+2"><%=[Link]("lname")%></font></td></tr> <tr><td><font face="Calibri" size="+2">Department</font></td><td><font face="Calibri" size="+2"><%=[Link]("dept")%></font></td></tr> <tr><td><font face="Calibri" size="+2">Designation</font></td><td><font face="Calibri" size="+2"><%=[Link]("desig")%></font></td></tr> <tr><td><font face="Calibri" size="+2">Age</font></td><td><font face="Calibri" size="+2"><%=[Link]("age")%></font></td></tr> <tr><td><font face="Calibri" size="+2">Phone No.</font></td><td><font face="Calibri" size="+2"><%=[Link]("phno")%></font></td></tr>
<tr><td><font face="Calibri" size="+2">E-Mail</font></td><td><font face="Calibri" size="+2"><%=[Link]("email")%></font></td></tr> </table> </center> <% } else { %> <center><h1><font face="Book Anitiqua">Record Not Found...!!!!</font></h1></center> <% } }catch(ClassNotFoundException e){ }catch(SQLException e){ }catch(Exception e){ } %> </body> </html>
<tr><td><font face="Calibri" size="+2">E-Mail</font></td><td><font face="Calibri" size="+2"><%=[Link]("email")%></font></td></tr> </table> </center> <% } else { %> <center><h1><font face="Book Anitiqua">Record Not Found...!!!!</font></h1></center> <% } }catch(ClassNotFoundException e){ }catch(SQLException e){ }catch(Exception e){ } %> </body> </html>
Implementation of Login Page in jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Login Page</title> </head> <body> <center><h1><font face="Book Anitiqua">Sign In</font></h1> <form method="POST" action="[Link]"> <table border="0"> <tr> <td><font face="Calibri" size="+2">User Name</font></td> <td><input type="text" name="uname"></td> </tr> <tr> <td><font face="Calibri" size="+2">Password</font></td> <td> <input type="password" name="pwd"> </td> </tr> </table> <br><input type="submit" value="Login"><input type="reset" value="Reset"> </form> </center> </body> </html>
[Link]
<%@page import="[Link].*,[Link].*,[Link].*" contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Welcome! </title> </head> <body> <% String uname = [Link]("uname"); String pwd = [Link]("pwd");
%> <% try{ [Link]("[Link]"); Connection con = [Link]("jdbc:odbc:MyDSN"); PreparedStatement pstmt = [Link]("select * from info where uname = ? and password = ?"); [Link](1, uname); [Link](2, pwd); ResultSet rst = [Link](); if([Link]()) { %> <jsp:forward page="[Link]" ></jsp:forward> <% } else{ %> <jsp:include page="[Link]"></jsp:include> <% } }
catch(ClassNotFoundException e){ }catch(SQLException e){ [Link](e); }catch(Exception e){ } %>
</body> </html>