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:

2. source file name: EmpSalary.jsp

<%
         
   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:

3. source file name: error.html

<html>
    <head>
        <title>Error page</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width">
    </head>
    <body>
        <h1> Error Found</h1>
        <h2>error due to salary less than 10000</h2>
    </body>
</html>

output: