In this code, when user adds delete button, raw is being deleted from database, but user is being redirected to empty home page, unless he logs out and logs in again. how can I fix the code, so that when he deletes something, whole layout is not disappearing, but only the line that he deleted.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<script type="text/javascript">
function del() {
if (confirm("Do You Want to Delete this Menu?")) {
} else {
return false;
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<link rel="stylesheet" href="images/style.css" type="text/css"
charset="utf-8" />
</head>
<body>
<%
menu_slno1 = request.getParameter("menu_slno");
if (menu_slno1 != null)
menu_slno = Integer.parseInt(menu_slno1);
delete_menu = request.getParameter("delete_menu");
if ("yes".equals(delete_menu)) {
MenuId = request.getParameter("MenuId");
x = stmt1
.executeUpdate("Delete from menu where MenuId="
+ MenuId);
}
%>
<center><h2>VIEW MENU</h2></center>
<center><table width="736" height="97" border="1"></center>
<%
if (x == 1) {
%>
<tr bgcolor="gray">
<th height="35" colspan="9"><div align="center">
Menu deleted successfully!
</div></th>
</tr>
<%
}
%>
<tr bgcolor="gray">
<td><div align="center">
<strong>Menu ID</strong>
</div></td>
<td><div align="center">
<strong>Name </strong>
</div></td>
<td><div align="center">
<strong>Info</strong>
</div></td>
<td><div align="center">
<strong>Price</strong>
</div></td>
<td colspan="2"><div align="center">
<strong>Action</strong>
</div></td>
</tr>
<%
String sUserID=request.getParameter("username");
session.setAttribute("username", sUserID);
int icount = 0;
rs = stmt.executeQuery("SELECT menu.menuID, menu.name, menu.info, menu.price, menu.RestaurantID FROM menu INNER JOIN clients ON menu.username = clients.username where menu.username='" +sUserID+ "'");
while (rs.next()) {
//menu_slno = rs.getInt("menu_slno");
MenuId = rs.getString("MenuId");
%>
<tr>
<td><div align="center"><%=++icount%></div></td>
<td><%=rs.getString("Name")%></td>
<td><%=rs.getString("Info")%></td>
<td><%=rs.getDouble("Price")%></td>
<td><div align="center">
<a href="edit_menu.jsp?MenuId=<%=MenuId%>">Edit</a>
</div></td>
<td><div align="center">
<a
href="view_menu.jsp?delete_menu=yes&MenuId= <%=MenuId%>&MenuId=<%=MenuId%>"
onclick="return del()">Delete</a>
</div></td>
</tr>
<%
}
%>
</table>
<a href="add_menu.jsp">Add Menu</a>
</body>
</html>