Program-2
Filename : Purchase_order_form.html
<html>
<head>
<title>PurchaseOrderForms</title>
</head>
<body>
<h2>Purchase Order Forms</h2>
<form name="Purchase_order_form"action="ProcessPurchaseOrderServlet"
method="post">
<label for="cust_name">Customer Name:</label>
<input type="text"id="cust_name"name="cust_name"required><br>
<label for="place">Place:</label>
<input type="text"id="place"name="place"required><br>
<label for="contact_number">Contact Number:</label>
<input type="number"id="contact_number"name="contact_number"
required><br>
<label for="date">Date:</label>
<input type="text"id="date"name="date"required><br>
<label for="product_name">Product Name:</label>
<input type="text"id="product_name"name="product_name"required><br>
<label for="quantity">Quantity:</label>
<input type="number"id="quantity"name="quantity"required><br>
<label for="unit_price">Unit Price:</label>
<input type="text"id="unit_price"name="unit_price"required><br>
<button type="submit">Submit Purchase List</button>
</form>
</body>
</html>
Filename:[Link]
import [Link].*;
import [Link].*;
import [Link].*;
import [Link];
import [Link];
import [Link];
public class ProcessPurchaseOrderServlet extends HttpServlet
{
private static final long serialVersionUID=1L;
protected void doPost(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException
{
String productName=[Link]("product_name");
int quantity=[Link]([Link]("quantity"));
double unitprice=[Link]([Link]("unit_price"));
String custname=[Link]("cust_name");
long contactnumber=[Link]([Link]
("contact_number"));
String place=[Link]("place");
String date=[Link]("date");
double totalCost=quantity * unitprice;
[Link]("text/html");
PrintWriter out=[Link]();
[Link]("<html><body>");
[Link]("<h1>      
         
XYZ Companies  </h1>");
[Link]("<h2>        
         
Purchase Order Summary  </h1>");
[Link]("<table style=width:700px>");
[Link]("<tr><th>Customer Name:"+custname+"</th><th>Distributer
code:DC001</th></tr>");
[Link]("<tr><th>Customer Place:"+place+"</th><th>Purchase Order
code:PC001</th></tr>");
[Link]("<tr><th>Contact
Number:"+contactnumber+"</th><th>Date:"+date+"</th></tr>");
[Link]("</table>");
[Link]("<table border=1 bgcolor=lightblue style=width:700px>");
[Link]("<tr><th>ProductName</th><th>Quantity</th><th>UnitPrice</th><th>TotalC
ost</th></tr>");
[Link]("<tr><th>"+productName+"</th><th>"+quantity+"</th><th>"+unitprice+"</th
><th>"+totalCost+"</th></tr>");
[Link]("</table>");
[Link]("</body></html>");
}
}
Output: