JSP Java code to Delete Record using SQL and apache server

delstud.jsp

<%@page session="true"import="java.io.*"%>
<html>
<body bgcolor="#d0d0d0">
<br></br>
<br></br>
<br></br>
<h2><center>enter stuent details</center></h2>
<form name="delstud"action="delstudinfo.jsp"method="post">
<table border="2"align=center>
<tr><td>
<b>id:</b>
<input type="text"name="id"/>
<br/>
<br/>
</td></tr>
</table>
<center>
<input type="submit"value="submit"/>
<input type="reset"value="reset"/>
<input type="button"value="delete"/>
</form>
</body>
</html>


delstudinfo.jsp

<%@page session="true"import="java.io.*"%>
<html>
<body bgcolor="#d0d0d0">
<br></br>
<br></br>
<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<%
Connection con=null;
Statement stmt=null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:student1","sa","sa");
try
{

String s2=request.getParameter("id");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:student1","sa","sa");
stmt=con.createStatement();
stmt.executeUpdate("delete from studentinfo where id1='"+s2+"'");
%>
data deleted successfully...........
<%
stmt.close();
stmt=null;
}
finally
{
if(con!=null)
{
con.close();
}
}
%>
</body>
</html>

OUTPUT:


0 comments:

Post a Comment

If You Are Asking Some Question On This Comment Then Click On Subscribe by email Link