This tutorial will teach you Jsp Servlet Sales Project Step by Step.This project will help you to manage the sales of the shop.
index.jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>JSP Page</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> <script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> </head> <body> <div class="container"> <div class="row"> <form method="get" action="servlet"> <div class="col-sm-04"> <label>Do you Want to Drink</label> <select class="form-control" id="drink" name="drink"> <option value="">Please Select Drink</option> <option value="pepsi">Pepsi</option> <option value="cock">Cock</option> </select> </div> <div class="col-sm-04"> <label>Qty</label> <input type="text" name="qty" id="qty" class="form-conrol"> </div> <div class="col-sm-04"> <input type="submit" value="Submit" class="btn btn-success"> </div> </form> </div> </div> </body> </html>
servlet.java
import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet("/servlet") public class servlet extends HttpServlet { @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String item = request.getParameter("drink"); String qty = request.getParameter("qty"); int qtty=0; int price = 0; float discount= 0.0f; if(item.equals("pepsi")) { price =25; discount = 10; qtty = Integer.parseInt(qty); float amount = qtty * price; float disamount = amount * discount/100.0f; float bill = amount - disamount; out.println("<form method='get' action='servlet'>"); out.println("<table border=2 cellpadding=0 cellspacing=0>"); out.println("<tr>"); out.println("<td colspan=2>Order Details</td>"); out.println("</tr>"); out.println("<tr><td>Drink</td> <td> " + item + "</td></tr>"); out.println("<tr><td>Price</td> <td> " + price + "</td></tr>"); out.println("<tr><td>Amount</td> <td> " + amount + "</td></tr>"); out.println("<tr><td>DiscountAmount</td> <td> " + disamount + "</td></tr>"); out.println("<tr><td>Bill</td> <td> " + bill + "</td></tr>"); out.println("</table>"); out.println("</form>"); } else if(item.equals("cock")) { price =30; discount = 5; qtty = Integer.parseInt(qty); float amount = qtty * price; float disamount = amount * discount/100.0f; float bill = amount - disamount; out.println("<form method='get' action='servlet'>"); out.println("<table border=2 cellpadding=0 cellspacing=0>"); out.println("<tr>"); out.println("<td colspan=2>Order Details</td>"); out.println("</tr>"); out.println("<tr><td>Drink</td> <td> " + item + "</td></tr>"); out.println("<tr><td>Price</td> <td> " + price + "</td></tr>"); out.println("<tr><td>Amount</td> <td> " + amount + "</td></tr>"); out.println("<tr><td>DiscountAmount</td> <td> " + disamount + "</td></tr>"); out.println("<tr><td>Bill</td> <td> " + bill + "</td></tr>"); out.println("</table>"); out.println("</form>"); } } }
Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…
Act as a Java developer to create a program that calculates the gross wage for…
Initialize the employee number, Hourswork,and Hoursrate to calculate a grosswage use the following condition. if…
In this tutorial, we will teach you how to create a simple school management system…
I have design the Admin Basic templete using React MUI Design Admin Dashboard and Login.Here…
In this tutorial ,i am to going teach the Laravel Breeze.Laravel Breeze provides a simple…