BCA

WEB PROGRAMMING LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 PROGRAM 15 . . .

10. Write a JSP application to evaluate the salary details of an employee and store the same in the ms access database table.
OUTPUT: Employee Details

Enter Employee Details :

EMPLOYEE NAME:
EMPLOYEE ID:
DESIGNATION:
BASIC SALARY:
TA(%):
DA(%):
HRA(%):
PF(%):
LIC(%):

PAGE 1: program10startpage.html

 
 

<html>
<head>
<title>Employee Details</title>
</head>

<body>
<h3>Enter Employee Details :</h3>
<form action="program10endpage.jsp" method="POST">
<table>
<tr><td>EMPLOYEE NAME:</td><td><input type="text" name="ename" autofocus></td></tr>
<tr><td>EMPLOYEE ID:</td><td><input type="text" name="empid"></td></tr>
<tr><td>DESIGNATION:</td><td><input type="text" name="des"></td></tr>
<tr><td>BASIC SALARY:</td><td><input type="text" name="bsal"></td></tr>
<tr><td>TA(%):</td><td><input type="text" name="ta"></td></tr>
<tr><td>DA(%):</td><td><input type="text" name="da"></td></tr>
<tr><td>HRA(%):</td><td><input type="text" name="hra"></td></tr>
<tr><td>PF(%):</td><td><input type="text" name="pf"></td></tr>
<tr><td>LIC(%):</td><td><input type="text" name="lic"></td></tr>
<tr><td><input type="submit" value="SUBMIT"></td>
<td><input type="reset" value="RESET"></td></tr>
</table>
</form>
</body>
</html>


PAGE 1: program10endpage.jsp

 
 

<html>
<head><title>PERSON INFORMATION</title>
<%@ page import="java.sql.*"%>
</head>
<body>
<%
int ID=Integer.parseInt(request.getParameter("empid"));
String NAME=request.getParameter("ename");




String des2= request.getParameter("des");

int b3=Integer.parseInt(request.getParameter("bsal"));

int ta4=Integer.parseInt(request.getParameter("ta"));

int da5=Integer.parseInt(request.getParameter("da"));

int har6=Integer.parseInt(request.getParameter("hra"));

int pf7=Integer.parseInt(request.getParameter("pf"));

int lic8=Integer.parseInt(request.getParameter("lic"));
 
double TA=(ta4/100.0)*b3;
double DA=(da5/100.0)*b3;
double HRA=(har6/100.0)*b3;

 
double PF=(pf7/100.0)*b3;
double LIC=(lic8/100.0)*b3;

double GrossSalary=(int)b3+TA+DA+HRA;
double NetSalary=GrossSalary-(PF+LIC);

java.util.Formatter formatter = new java.util.Formatter();
formatter.format("%.2f", GrossSalary);

try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:person");
PreparedStatement p;

  p=con.prepareStatement("insert into table1 values('"+ID+"','"+NAME+"' ,'"+dept1+"','"+des2+"','"+b3+"','"+ta4+"','"+da5+"','"+har6+"','"+pf7+"','"+lic8+"')");

int rs=p.executeUpdate();
if(rs>0)
{
	out.print("DATA INSERTED SUCCESSFULLY");
}
else
{
	out.print(" NOT CONNECTED");
}
}
catch(Exception e)
{
	out.println(e);
}
%>




</body>

<style>

.table{
	border: 1px solid black;
	
}

.table th{
	border: 1px solid black;
	
}
.table td{
	border: 1px solid black;
	
}
	
</style>
<table>


<tr><td>
 

</td></tr>


<tr><td>
<center>EMPLOYEE NAME:</td><td><label type="text" name="pname"><%= NAME %></label>

</td></tr>
<tr><td>
<center>EMPLOYEE ID:</td><td><label type="number" name="pid"><%= ID %></label>

</td></tr>
</table>

<table class="table">
 

<tr><td>
<center>Department  :</td>
 
<td><label type="text" name="s1"><%= dept1 %></label>

</td></tr>

<tr><td>
<center>Designation :</td>
 
 <td><label type="text" name="s2"><%= des2 %></label>

</td></tr>

<tr><td>
<center>Basic Salary :</td>
 <td><label type="text" name="s3"><%= b3 %></label>

</td></tr>

<tr><td>
<center>TA   :</td>
 <td><label type="text" name="s4"><%= TA %></label>

</td></tr>

<tr><td>
<center>DA :</td>

 <td><label type="text" name="s5"><%= DA %></label>

</td></tr>

<tr><td>
<center> HRA :</td>
 <td><label type="text" name="s6"><%= HRA %></label>
</td></tr>
 
<tr>
<td><center>PF : </center>  </td>
<td>
<%= PF %>
</td></tr> 

<tr>
<td><center>LIC: </center>  </td>
<td>
<%= LIC %>

</td></tr>

<tr><td>
<center> Gross Salary :</td>

 <td><label type="text" name="s7"><%= GrossSalary %></label>
</td></tr>
 <tr> 


<td>Net Salary :   </td>
<td>
<%= NetSalary %>

</td></tr>
</table>
</html>