0% found this document useful (0 votes)
83 views

Log - JSP: Width 150 Eg: 0001 (Max 6)

The document contains code for a login page, login action page, and other pages related to an employee leave management system. The login page contains a form to enter user ID, password and role. The login action page authenticates the user and redirects to different pages based on the user role. Other pages allow changing password, creating new users, and applying for leave. The code uses JSP, HTML, and connects to a database using JDBC to retrieve and store user and leave data.

Uploaded by

Fiyona Castelino
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Log - JSP: Width 150 Eg: 0001 (Max 6)

The document contains code for a login page, login action page, and other pages related to an employee leave management system. The login page contains a form to enter user ID, password and role. The login action page authenticates the user and redirects to different pages based on the user role. Other pages allow changing password, creating new users, and applying for leave. The code uses JSP, HTML, and connects to a database using JDBC to retrieve and store user and leave data.

Uploaded by

Fiyona Castelino
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

log.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.

dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Login form</title> </head> <body alink="red" vlink="blue" > <h1 align="center"><img src="C:\workspace\leave\image.jpg" width="300" height="150"></h1> <form method=post action=log_action.jsp name=f1 > <table align=center border=2 bordercolor="GREEN" bgcolor="silver"> <tr><td height=25 width=100><b>User Id</b><td height=25 width=150><input type="text" name=t1 > Eg: 0001 (max=6) <tr><td height=25 width=100><b>Password</b><td height=25 width=200><input type="password" name=t2 > <tr><td height=25 width=100><b>Role</b><td height=25 width=100><select name=t3> <option value=1>Normal user</option> <option value=2>Approver</option> <option value=3>Administrator</option> </select> <tr><td height=25 width=100 align="center"><input type=submit

value="Login" ><td height=30 width=100 align="center"><input type=reset value="Reset"> </table> <h6 align=center> <a href="home.jsp"><img src = "C:\workspace\leave\homeimg.gif" width=40 height=35></a></h6> </form> </body> </html>

log_action.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body alink="red" vlink="blue"> <% String u=request.getParameter("t1"); String p=request.getParameter("t2"); String r=request.getParameter("t3"); session.setAttribute("user",u); session.setAttribute("pass",p);

session.setAttribute("rl",r); if (u=="" || p=="" || r=="") { out.println("Enter all the values"); out.println("<br>"); out.println("<br>"); out.println("<a href=log.jsp><u><b>Login</b></u></a>"); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:elms","scott", "inat"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from user_table where user_id='"+u+"'"); int v=0; while(rs.next()) { String pswd=rs.getString(2); String role=rs.getString(3); String e=rs.getString(4); session.setAttribute("emp",e); if( p.equals(pswd))

{ if(r.equals(role)) { int i=Integer.parseInt(r); if(i==1) { v=1; %> <a href="emppage.jsp">Go to EMPLOYEE page</a> <h1 align=center>You are logged in as an Employee</h1> <% } else if(i==2) { v=1; %> <a href="apppage.jsp">Go to APPROVER page</a> <h1 align=center>You are logged in as an Approver</h1> <% } else if(i==3) { v=1; %> <a href="adminpage.jsp">Go to ADMINISTRATOR page</a> <h1 align=center>You are logged in as an Administrator</h1>

<% } } } } if(v==0) { out.println("Check for correct user id, password and role"); out.println("<br>"); out.println("<br>"); out.println("<a href=log.jsp><u><b>Login</b></u></a>"); } Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn1 = DriverManager.getConnection("jdbc:odbc:elms","scott", "inat"); Statement stmt1=conn1.createStatement(); ResultSet rs1=stmt1.executeQuery("select * from employee where emp_id='"+ session.getAttribute("emp") +"'"); if(rs1.next()) { String s=rs1.getString("first_name"); String d=rs1.getString("dept_id"); session.setAttribute("name",s); ResultSet rs3=stmt1.executeQuery("select * from department where dept_id='"+d+"'"); if(rs3.next())

{ String a=rs3.getString("appr"); ResultSet rs4=stmt1.executeQuery("select * from employee where emp_id='"+a+"'"); if(rs4.next()) { String an=rs4.getString("first_name"); session.setAttribute("appr",an); } } ResultSet rs2=stmt1.executeQuery("select * from department where dept_id='"+d+"'"); if(rs2.next()) { String dn=rs2.getString(2); session.setAttribute("dept",dn); } } }catch(Exception e) { out.println("Enter proper numeric value"); out.println("<br>"); out.println("<br>"); out.println("<a href=log.jsp><u><b>Login</b></u></a>"); } }

%> </body> </html>

chpswd.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title> Change Employee Password</title> </head> <body alink="red" vlink="blue"> <h4 align=right><a href="emppage.jsp"><u>Go Back</u></a></h4> <h1 align=center>Change Password</h1> <form method=post action="chpswd_action.jsp"> <table border=2 align=center bgcolor=silver> <tr><th>Old Password<td><input type=password name=t1> <tr><th>New Password<td><input type=password name=t2> <tr><th>Confirm Password<td><input type=password name=t3> <tr><td align=center><input type=submit value="Change"><td align=center><input type=reset> </table> </form>

</body> </html>

chpswd_action.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body alink="red" vlink="blue"> <% String op=request.getParameter("t1"); String np=request.getParameter("t2"); String cp=request.getParameter("t3"); if((op=="")||(np=="")||(cp=="")) { out.println("<font size=4>Enter all the values</font>"); out.println("<br>"); out.println("<br>"); out.println("<a href=chpswd.jsp>Change</a>"); } else

{ session.getAttribute("emp"); String p; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn = DriverManager.getConnection("jdbc:odbc:elms","scott", "inat"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select password from user_table where user_id='" +session.getAttribute("user")+ "' "); if(rs.next()) { p=rs.getString("password"); if(op.equals(p)) { if(np.equals(cp)) { String q="update user_table set password='"+cp+"' where user_id ='" +session.getAttribute("user")+ "'"; stmt.executeUpdate(q); out.println("<font size=4>Password successfully updated</font>"); %> <br><br><a href=emppage.jsp>Go to Employee page</a> <% } else {

out.println("<font size=4>New and confirm password should be same</font>"); out.println("<br>"); out.println("<br>"); out.println("<br><a href=chpswd.jsp>Change</a>"); } } else { out.println("<font size=4>Invalid current password</font>"); out.println("<br>"); out.println("<br>"); out.println("<br><a href=chpswd.jsp>Change</a>"); } } } %> </body> </html>

createuser.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html>

<head> <meta http-equiv="Content-Type" content="text/html; charset=ISO8859-1"> <title>Create user-id</title> </head> <body alink="red" vlink="blue"> <h4 align=right><a href=adminpage.jsp>Go Back</a></h4> <h1 align=center>Create User Id </h1> <form method=post action=create_action.jsp onsubmit=validate()> <table border=2 align=center bgcolor=silver> <tr><th>User ID<td><input type=text name=t1> <tr><th>Password<td><input type=password name=t2> <tr><th>Role<td><select name=t3> <option value=1>Basic</option> <option value=2>Approver</option> <option value=3>Administrator</option> </select> <tr><th>Employee ID<td><input type=text name=t4> <tr><td align=center><input type=submit value="Create"><td align=center><input type=reset> </table> </form> </body> </html>

create_action.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1"

pageEncoding="ISO-8859-1" import="java.sql.*;" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body alink="red" vlink="blue"> <% String user=request.getParameter("t1"); String pswd=request.getParameter("t2"); String role=request.getParameter("t3"); String emp=request.getParameter("t4"); if((user=="") || (pswd=="") ||(role=="") || (emp=="")) { out.println("Enter all the values"); out.println("<br>"); out.println("<br>"); out.println("<a href=create.jsp>Create</a>"); } else { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery("select * from user_table where user_id like '"+user+"'"); if(rs.next()) { String r=rs.getString(3); if(r.equals(role)) { out.println("Record already exists"); out.println("<a href=create.jsp>Create</a>"); } else { stmt.executeUpdate("insert into user_table values('"+user+"','"+pswd+"','"+role+"','"+emp+"')" ); out.println("User ID successfully created"); } } else { stmt.executeUpdate("insert into user_table values('"+user+"','"+pswd+"','"+role+"','"+emp+"')" ); out.println("Successfully added"); out.println("<a href=create.jsp>Create</a>"); } } %> </body>

</html>

apply.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Leave Application</title> </head> <body alink="red" vlink="blue"> <h2 align=center>Leave Application</h2> <form method=post action="apply_action.jsp"> <table border=1 align=center bgcolor="silver"> <tr> <th width=300 height=15>Leave Type <th width=300 height=15>From Date<th width=300 height=15>To Date<th width=300 height=15>Half Day From<th width=300 height=15>Half Day To<th width=300 height=15>Description</th> <tr><td align=center><input type="checkbox" name=t3 value=1>CL <tr><td align=center><input type="checkbox" name=t9 value=2>PL <td><input type=text name=t4><td><input type=text name=t5> <td><select name=t6> <option value='N'>No</option> <option value='Y'>Yes</option>

</select> <td><select name=t7> <option value='N'>No</option> <option value='Y'>Yes</option> </select> <td><textarea name=t8 rows=3 cols=15></textarea> <tr><td align=center><input type="checkbox" name=t15 value=3>EL <tr><th align=center colspan=6>Send To <input type=text name=t21 width=500 value=<%=session.getAttribute("appr") %> disabled> <tr><td align=center colspan=6><input type=submit value="Apply"><input type=reset value="Clear"> </table> </form> </body> </html>

apply_action.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" import="java.util.*" import="java.text.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head>

<body alink="red" vlink="blue"> <% String lt1=request.getParameter("t3"); String lt2=request.getParameter("t9"); String lt3=request.getParameter("t15"); String fd1=request.getParameter("t4"); String td1=request.getParameter("t5"); String hf1=request.getParameter("t6"); String ht1=request.getParameter("t7"); String desc1=request.getParameter("t8"); String apid=request.getParameter("t21"); if(((lt1=="") || (lt2=="") || (lt3=="")) || ((fd1=="") || (td1=="") || (desc1==""))) { out.println("<font size=4>Enter all the values</font>"); out.println("<br>"); out.println("<br>"); out.println("<a href=apply.jsp>Apply</a>"); } else { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt=conn.createStatement();

ResultSet rs=stmt.executeQuery("select count(appln_id) from leave_appln where emp_id='"+session.getAttribute("emp")+"'"); if(rs.next()) { String a=rs.getString(1); int a1=Integer.parseInt(a); a1=a1+1; stmt.executeUpdate("insert into leave_appln values('"+a1+"','"+session.getAttribute("emp")+"','"+fd1+"','"+td1+"','"+hf1+"','"+ht 1+"','"+desc1+"','"+1+"')"); ResultSet rs1=stmt.executeQuery("select count(inb_id) from appinbox where emp_id='"+session.getAttribute("emp")+"'"); if(rs1.next()) { String i=rs1.getString(1); int i1=Integer.parseInt(i); i1=i1+1; stmt.executeUpdate("insert into appinbox values('"+i1+"','"+session.getAttribute("emp")+"','"+fd1+"','"+td1+"','"+1+"','"+a1+ "')"); stmt.executeUpdate("insert into adminbox values('"+i1+"','"+session.getAttribute("emp")+"','"+fd1+"','"+td1+"','"+1+"','"+a1+ "')"); if(lt1!=null) { ResultSet rs2=stmt.executeQuery("select count(type_id) from type where emp_id='"+session.getAttribute("emp")+"'"); if(rs2.next())

{ String t=rs2.getString(1); int t1=Integer.parseInt(t); t1=t1+1; stmt.executeUpdate("insert into type values('"+t1+"','"+session.getAttribute("emp")+"','"+a1+"','"+lt1+"')"); } } if(lt2!=null) { ResultSet rs2=stmt.executeQuery("select count(type_id) from type where emp_id='"+session.getAttribute("emp")+"'"); if(rs2.next()) { String t=rs2.getString(1); int t1=Integer.parseInt(t); t1=t1+1; stmt.executeUpdate("insert into type values('"+t1+"','"+session.getAttribute("emp")+"','"+a1+"','"+lt2+"')"); } } if(lt3!=null) { ResultSet rs2=stmt.executeQuery("select count(type_id) from type where emp_id='"+session.getAttribute("emp")+"'"); if(rs2.next()) {

String t=rs2.getString(1); int t1=Integer.parseInt(t); t1=t1+1; stmt.executeUpdate("insert into type values('"+t1+"','"+session.getAttribute("emp")+"','"+a1+"','"+lt3+"')"); } } } } out.println("Leave application sent"); } catch(Exception e) { out.println("<font size=4>Date must be in the DD-MM-YYYY format</font>"); out.println("<br>"); out.println("<br>"); out.println("<a href=apply.jsp>Apply</a>"); } } %> </body> </html>

add.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Add Employee</title> </head> <body alink="red" vlink="blue"> <h2 align=center>Add Employee Details</h2> <form method=post action="add_action.jsp"> <table align=center border=1 bgcolor="silver"> <tr><th width=150>Employee no<td width=100><input type=text name=t1> <tr><th>First name<td><input type=text name=t2> <tr><th>Middle name<td><input type=text name=t3> <tr><th>Last name<td><input type=text name=t4> <tr><th>Address<td><textarea rows=3 cols=16 name=t5></textarea> <tr><th>City<td><input type=text name=t6> <tr><th>Pincode<td><input type=text name=t7> <tr><th>State<td><input type=text name=t8> <tr><th>Sex<td><select name="t9"> <option value="M">Male</option> <option value="F">Female</option> </select> <tr><th>Landline no<td><input type=text name=t10> <tr><th>Mobile no<td><input type=text name=t11> <tr><th>Email-Id<td><input type=text name=t12>

<tr><th>Designation<td><input type=text name=t13> <tr><th>Department<td><select name=t14> <option value=1>HR</option> <option value=2>Coding</option> <option value=3>Testing</option> <option value=4>Accounts</option> </select> <tr><th>Grade<td><select name=t15> <option value=1>Tier1</option> <option value=2>Tier2</option> <option value=3>Tier3</option> <option value=4>Tier4</option> </select> </table> <br> <table align=center> <tr><th align=center><input type=submit value=Add><td align=center><input type=reset> </table> </form> </body> </html>

add_action.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body alink="red" vlink="blue"> <% String empid=request.getParameter("t1"); String fname=request.getParameter("t2"); String mname=request.getParameter("t3"); String lname=request.getParameter("t4"); String add=request.getParameter("t5"); String city=request.getParameter("t6"); String pcode=request.getParameter("t7"); String state=request.getParameter("t8"); String sex=request.getParameter("t9"); String landline=request.getParameter("t10"); String mobile=request.getParameter("t11"); String email=request.getParameter("t12"); String desg=request.getParameter("t13"); String dept=request.getParameter("t14"); String grade=request.getParameter("t15");

if((empid=="") || (fname=="") || (lname=="") || (add=="") || (city=="") || (pcode=="") || (state=="") || (sex=="") || (email=="")|| (desg=="") || (dept=="") || (grade=="")) { out.println("Enter all the values"); out.println("<br>"); out.println("<br>"); out.println("<a href=add.jsp>Add</a>"); } else { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from employee where emp_id like '"+empid+ "'"); if(rs.next()) { out.println("Record already exists"); out.println("<br><a href=add.jsp>Go back</a>"); } else { try { int empid1=Integer.parseInt(empid); int pcode1=Integer.parseInt(pcode);

int landline1=Integer.parseInt(landline); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn1=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt1=conn1.createStatement(); int q1=stmt.executeUpdate("insert into employee values('"+empid+"','"+fname+"','"+mname+"','"+lname+"','"+add+"','"+city+"','"+pc ode+"','"+state+"','"+sex+"','"+landline+"','"+mobile+"','"+email+"','"+desg+"','"+dep t+"','"+grade+"')"); int c=1; int i=1; String a="0"; String y="2009"; while(i<=3) { ResultSet rs2=stmt1.executeQuery("select * from max_leave where grade_id='"+grade+"' and leave_id='"+i+"'"); if(rs2.next()) { String m=rs2.getString("maxdays"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn2=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt2=conn2.createStatement(); int q2=stmt1.executeUpdate("insert into yearwise_leave values('"+c+"','"+empid+"','"+i+"','"+a+"','"+m+"','"+y+"')"); } i++;

c++; } out.println("Successfully added"); } catch(Exception e) { out.println("Enter proper numeric values"); out.println("<br>"); out.println("<br>"); out.println("<a href=add.jsp>Add</a>"); } } } %> </body> </html>

displayall.jsp <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.sql.*" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Display all</title> </head> <body alink="red" vlink="blue">

<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn=DriverManager.getConnection("jdbc:odbc:elms","scott", "inat"); Statement stmt=conn.createStatement(); ResultSet rs=stmt.executeQuery("select * from employee order by emp_id"); out.println("<h1 align=center>Employee Details</h1>"); out.println("<table border=1><tr><th>Empno<th>First name<th>Middle name<th>Last name<th>Address<th>City<th>Pincode<th>State<th>Sex<th>Landline<th>Mobile no<th>Email-Id<th>Designation<th>Grade<th>Department<th>Approved by<th>Role"); while(rs.next()) { String e=rs.getString("emp_id"); out.println("<tr><td>"+e); out.println("<td>"+rs.getString("first_name")); out.println("<td>"+rs.getString("middle_name")); out.println("<td>"+rs.getString("last_name")); out.println("<td>"+rs.getString("address")); out.println("<td>"+rs.getString("city")); out.println("<td>"+rs.getString("pincode")); out.println("<td>"+rs.getString("state")); out.println("<td>"+rs.getString("sex")); out.println("<td>"+rs.getString("landline")); out.println("<td>"+rs.getString("mobile")); out.println("<td>"+rs.getString("email_id")); out.println("<td>"+rs.getString("desg")); String d=rs.getString("dept_id"); String g=rs.getString("grade_id"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn3=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt3=conn3.createStatement(); String q1="select * from grade where grade_id ='"+g+"'"; ResultSet rs2=stmt3.executeQuery(q1);

if(rs2.next()) { String g1=rs2.getString(2); out.println("<td>"+g1); } Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn2=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt2=conn2.createStatement(); ResultSet rs1=stmt2.executeQuery("select * from department where dept_id ='"+d+"'"); if(rs1.next()) { String d1=rs1.getString(2); String ap=rs1.getString(3); out.println("<td>"+d1); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn5=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt5=conn5.createStatement(); ResultSet rs4=stmt5.executeQuery("select * from employee where emp_id ='"+ap+"'"); if(rs4.next()) { String a1=rs4.getString(2); String a2=rs4.getString(4); out.println("<td>"+a1+" "+a2); } } Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection conn4=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt4=conn4.createStatement(); ResultSet rs5=stmt4.executeQuery("select * from user_table where emp_id='"+e+"'"); while(rs5.next()) { String r=rs5.getString("role_id"); Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Connection conn5=DriverManager.getConnection("jdbc:odbc:elms","scott","inat"); Statement stmt5=conn5.createStatement(); ResultSet rs3=stmt5.executeQuery("select * from role where role_id ='"+r+"'"); if(rs3.next()) { String r1=rs3.getString(2); out.println("<td>"+r1); } } } %> </body> </html>

You might also like