Program 1
<%--
Document : InsertProduct
Created on : Nov 6, 2023, 1:22:08 PM
Author : admin
--%>
<%@page import="model.Product"%>
<%@page import="dao.ProductDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="header.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
for(int i=1;i<=15;i++)
out.println("<br>");
%>
<center>
<font color="F19A15" size="7">Delete Product By Id</font>
<br>
<form method="post" action="deleteProduct.jsp">
<table border="1">
<tr>
<th>Enter Product Id:</th>
<td><input type="text" name="txtid"></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" value="Delete">
<input type="reset" value="Reset">
</td>
</tr>
</table>
</form>
<%
String prodid=null;
int pid;
prodid=request.getParameter("txtid");
if(prodid!=null)
{
pid=Integer.parseInt(prodid);
session.setAttribute("prodid", pid);
ProductDAO pd=new ProductDAO();
Product P=null;
P=pd.searchProduct(pid);
if(P==null)
out.println("<font color=red size=5>Record not found...</font>");
else
{
%>
<font color="red" size="5">Are You Sure want to delete Record</font>
<table border="1">
<tr>
<th>Prod Id</th><th>Prod Name</th><th>Qty</th><th>Amount</th><th>Type</th>
</tr>
<tr>
<td><%=P.getProdid()%></td>
<td><%=P.getProdname()%></td>
<td><%=P.getProdqty()%></td>
<td><%=P.getProdamt()%></td>
<td><%=P.getProdqty()%></td>
<form method="post" action="DeleteData.jsp">
<td><input type="submit" value="Delete"></td>
</form>
</tr>
<%
}
}
%>
</table>
</center>
</body>
</html>
Program 2
<%--
Document : DeleteData
Created on : Nov 8, 2023, 12:51:33 PM
Author : admin
--%>
<%@page import="dao.ProductDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@include file="header.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<center>
<%
for(int i=1;i<=15;i++)
out.println("<br>");
%>
<%
int id;
id=Integer.parseInt(session.getAttribute("prodid").toString());
ProductDAO pd=new ProductDAO();
if(pd.deleteRecord(id))
out.println("<h2>Record Deleted.............</h2>");
else
out.println("Record Not Found.............");
%>
</center>
</body>
</html>