by Dinesh Thakur Category: JSP Elements

When the bill amount exceeds Rs. 1000 then else part of calc.jsp gets executed and it forwards the request to discount.jsp page .

Bill.htm”

  <body bgcolor="cyan" >

  <br><center>

     <FONT color="red" size="7"> WELCOME TO BIG BAZAR </font>

  <br><br><br> <br>

  <form action="calc.jsp">

  PRODUCT NAME: <input type="text" name="t1" value="" size="20" /><br>

  NUMBER OF QUANTITY :<input type="text" name="t2" value="" size="20" />

  <br> PRICE<input type = "text" name="t3" value="" size="20" />

  <br> <input type="submit" value="SUBMIT" />

  <input type="Reset" value="Reset" />

  </form>

  </body>

           Bill Discount JSP Program

“Calc.jsp”

 

   <body bgcolor="cyan" >

   <br>

   <center>

   <FONT color="red" size="7"> WELCOME TO BIG BAZAR BILL PAGE

   <br><br><br>

   YOUR BILL IS,

   <%

          String pn=request.getParameter("t1");

          String qnty=request.getParameter("t2");

          String pr=request.getParameter("t3");

          int q=Integer.parseInt(qnty);

          int price=Integer.parseInt(pr);

          int bill=price*q;

          if (bill>1000)

          {

   %>  

              <jsp:forward page="discount.jsp">

              <jsp:param name="bill" value="<%=bill%>"/>

              </jsp:forward>

        <%

         }

           else

        {

           out.println(bill);

       }

        %>

             

discount.jsp”

 

  <body bgcolor="cyan" >

  <br>

  <center>

   <FONT color="red" size="7"> WELCOMETO BIG BAZAR DISCOUNT PAGE

   <br><br><br>

   YOUR TOTAL BILL IS : <%=request.getParameter("bill") %>

   <br>

   <br>

   <p>YOUR DISCOUNT BILL IS</p>

    <%

            int bill=Integer.parseInt(request.getParameter("bill"));

            int disc =((bill*30)/100);

            out.println(disc);

            int pay=bill-disc;

   %>

           <br><br> AFTER DISCOUNT 30 % BILL IS <%=pay %>

          </br>

                  Bill Discount JSP Program



About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.