Send Redirect example
reg.html
<html>
<body>
<form action="reg" method="post">
<table border="3" bgcolor="magenta">
<tr>
<td> eid:<input type="text" name="eid"/><br/><br/> </td></tr>
<tr><td>ename<input type="text" name="ename"/><br/><br/> </td></tr>
<tr><td>salary:<input type="text" name="esalary"/><br/><br/> </td></tr>
</table>
<input type="submit" value="click here"/>
</form>
</table>
</body>
</html>
reg.java
import java.io.*;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.*;
public class reg extends HttpServlet {
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String n=request.getParameter("eid");
String p=request.getParameter("ename");
String e=request.getParameter("esalary");
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con=DriverManager.getConnection(
"jdbc:derby://localhost:1527/kbn","kbn","kbn");
PreparedStatement ps=con.prepareStatement(
"insert into employee values(?,?,?)");
ps.setString(1,n);
ps.setString(2,p);
ps.setString(3,e);
int i=ps.executeUpdate();
if(i>0)
response.sendRedirect("success.html");
}
catch (Exception e2)
{
System.out.println(e2);
}
out.close();
}
}
success.html
<html>
<head>
<center>HOME PAGE</center>
<title>USE of INTERNAL and EXTERNAL STYLESHEETS
</title>
<link rel="stylesheet" href="xyz.css" type="text/css">
<style type="text/css">
.vid{font-family:verdana;font-style:italic;color:red;text-align:center}
.ani{font-family:tahoma;font-style:italic;font-size:20;text-align:center;}
font{font-family:georgia;color:blue;font-size:20}
ul{list-style-type:circle}
</style>
</head>
<body>
<ol style="list-style-type:lower-alpha">
<b>KBN COLLEGE</b><br><br><br>
<li>KBN DEGREE COLLEGE
<li>KBN PG COLLEGE
<li>POTTI SRIRAMULU ENGINEERING COLLEGE
</ol>
<p style="font-size:20pt;color:purple"></p>
<p class="ani">KBN GROUP IS OWNED BY SKPVV.<br>It is approved
by
It is affliated to KRISHNA UNIVERISTY.<br></p>
<h2 class="vid">KBN PG COLLEGE</h2>
<br>
<font>It is an ISO certified Institution</font><br>
<br>
<font>
List of Courses offered
<ul>
<li>M.Sc(cs)</li>
<li>MCA</li>
<li>MBA</li>
<li>MCOm</li>
</ul>
</font>
Results of MSc(CS) students
<table width="100%" cellspacing="2" cellpadding="2" border="5">
<tr>
<th>S.NAME</th>
<th>MARKS</th>
<th>RESULT</th>
</tr>
<tr>
<td align="center">duqluer</td>
<td align="center">100</td>
<td align="center">pass</td>
</tr>
<tr>
<td align="center">salman</td>
<td align="center">99</td>
<td align="center">pass</td>
</tr>
<tr>
<td align="center">satya</td>
<td align="center">98</td>
<td align="center">pass</td>
</tr>
</table>
</body>
</html>
kbn.css
h3{font-family:arial;font-size:20;color:cyan}
table{border-color:green}
td{font-size:20pt;color:magenta}
ReplyDeleteThanks for sharing such a good content with us. keep share these kind of content.i would like to read more.
Python Institute in Delhi