INDEX.HTML
<html>
<head>
<title>PAYROLL PROCESSING</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="payrollcalc.jsp">
Enter emp id:<input type="text" name="id"><br>
Enter emp Name:<input type="text" name="name"><br>
Enter emp Basic Pay:<input type="text" name="bp"><br>
Enter emp hra:<input type="text" name="hra"><br>
Enter emp da:<input type="text" name="da"><br>
Enter emp pf:<input type="text" name="pf"><br>
Enter emp lic:<input type="text" name="lic"><br>
<input type="submit" value="submit"><br>
</form>
</body>
</html>
PAYROLLCALC.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.ServletException"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%@ page import="javax.servlet.http.HttpServletResponse"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<%
try{
String id1=request.getParameter("id");
String name1=request.getParameter("name");
String bp1=request.getParameter("bp");
String hra1=request.getParameter("hra");
String da1=request.getParameter("da");
String pf1=request.getParameter("pf");
String lic1=request.getParameter("lic");
int bp2=Integer.parseInt(bp1);
int hra2=Integer.parseInt(hra1);
int da2=Integer.parseInt(da1);
int pf2=Integer.parseInt(pf1);
int lic2=Integer.parseInt(lic1);
int allowance=hra2+da2;
int deductions=pf2+lic2;
int GrossPay=bp2+allowance;
int netpay=GrossPay-deductions;
%>
<form target="_blank">
emp id:<input type="text" name="id" value=<%=id1%>><br>
emp Name:<input type="text" name="name" value=<%=name1%>><br>
emp Basic Pay:<input type="text" name="bp" value=<%=bp2%>><br>
emp hra:<input type="text" name="hra" value=<%=hra2%>><br>
emp da:<input type="text" name="da" value=<%=da2%>><br>
emp pf:<input type="text" name="pf" value=<%=pf2%>><br>
emp lic:<input type="text" name="lic" value=<%=lic2%>><br>
emp net pay:<input type="text" name="np" value=<%=netpay%>><br>
<input type="submit" value="submit"><br>
</form>
<%
}
catch(NumberFormatException exp){
out.println("There is something wrong:"+exp);
}
%>
</html>
OUTPUT:
<html>
<head>
<title>PAYROLL PROCESSING</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<form method="post" action="payrollcalc.jsp">
Enter emp id:<input type="text" name="id"><br>
Enter emp Name:<input type="text" name="name"><br>
Enter emp Basic Pay:<input type="text" name="bp"><br>
Enter emp hra:<input type="text" name="hra"><br>
Enter emp da:<input type="text" name="da"><br>
Enter emp pf:<input type="text" name="pf"><br>
Enter emp lic:<input type="text" name="lic"><br>
<input type="submit" value="submit"><br>
</form>
</body>
</html>
PAYROLLCALC.JSP
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.lang.*"%>
<%@ page import="java.util.*"%>
<%@ page import="javax.servlet.ServletException"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%@ page import="javax.servlet.http.HttpServletResponse"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<%
try{
String id1=request.getParameter("id");
String name1=request.getParameter("name");
String bp1=request.getParameter("bp");
String hra1=request.getParameter("hra");
String da1=request.getParameter("da");
String pf1=request.getParameter("pf");
String lic1=request.getParameter("lic");
int bp2=Integer.parseInt(bp1);
int hra2=Integer.parseInt(hra1);
int da2=Integer.parseInt(da1);
int pf2=Integer.parseInt(pf1);
int lic2=Integer.parseInt(lic1);
int allowance=hra2+da2;
int deductions=pf2+lic2;
int GrossPay=bp2+allowance;
int netpay=GrossPay-deductions;
%>
<form target="_blank">
emp id:<input type="text" name="id" value=<%=id1%>><br>
emp Name:<input type="text" name="name" value=<%=name1%>><br>
emp Basic Pay:<input type="text" name="bp" value=<%=bp2%>><br>
emp hra:<input type="text" name="hra" value=<%=hra2%>><br>
emp da:<input type="text" name="da" value=<%=da2%>><br>
emp pf:<input type="text" name="pf" value=<%=pf2%>><br>
emp lic:<input type="text" name="lic" value=<%=lic2%>><br>
emp net pay:<input type="text" name="np" value=<%=netpay%>><br>
<input type="submit" value="submit"><br>
</form>
<%
}
catch(NumberFormatException exp){
out.println("There is something wrong:"+exp);
}
%>
</html>
OUTPUT:
No comments:
Post a Comment