Write a JSP program that accepts Employee name and Basic salary , JSP calculates Gross Salary of Employee and Error page found if Salary is less than 10000 .
1. source file name: Emp,html
<html>
<head>
<title>Employee Salary Information </title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
</head>
<body>
<form action="http://localhost:8080/JspPrograms/EmpSalary.jsp" method="GET">
Enter Employee Name : <input type="text" name="username" size="50" />
<br >
Enter Basic Salary : <input type="number" name="sal" size="20" />
<br>
<input type="submit" value="Submit" />
</form>
</body>
</html>
output:
<%
String ename= request.getParameter("username");
int bs=Integer.parseInt(request.getParameter("sal"));
if(bs>=10000)
{
double da=bs*0.4;
double hra=bs*0.6;
double gs=bs+da+hra;
out.println("<h2>Empoyee's Name is : "+ename);
out.println("<br> <h2> Empoyee's Gross Salary: "+gs);
}
else
{
response.sendRedirect("error.html");
}
%>
output:
0 Comments
Post a Comment