<!-- 7. HTML Program to read Placement details of student. -->
<html>
<head>
<title>Student Information</title>
</head>
<body>
<h3>Enter Student Details:</h3>
<form action="Prog7.jsp" method="POST" >
<table >
<tr><td>Name:</td><td><input type="text" name="sname"></td></tr>
<tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
<tr><td>Course:</td><td> <select name="course">
<option >BCA</option>
<option >BSc</option>
<option >BA</option>
</select> </td></tr>
<tr><td>Combination:</td><td> <select name="comb">
<option >Computer Applications</option>
<option >PMCs</option>
<option >EMCs</option>
<option >HSP</option>
<option >HEK</option>
</select> </td></tr>
<tr><td>Placement Mode:</td><td> <select name="mode">
<option >OnCampus</option>
<option >OffCampus</option>
</select> </td></tr>
<tr><td>Name of Company:</td><td><input type="text" name="cname"></td></tr>
<tr><td>Employer Type:</td><td> <select name="etype">
<option >Private</option>
<option >Government</option>
</select> </td></tr>
<tr><td>Selection Date:</td><td><input type="text" name="sdate">[yyyy-mm-dd]</td></tr>
<tr><td>Package:</td><td><input type="text" name="pack"></td></tr>
<tr><td><input type="submit" value="Save in Database" ></td>
<td><input type="reset" value="Reset" ></td></tr>
</table>
</form>
</body>
</html>
<!-- 7. JSP Program to store Placement details of Students in MySQL Database. -->
<html>
<head>
<title>Student Information</title>
<%@page import="java.sql.*,java.util.*"%>
</head>
<body>
<%
try
{
String sname=request.getParameter("sname");
String regno=request.getParameter("regno");
String course=request.getParameter("course");
String comb=request.getParameter("comb");
String mode=request.getParameter("mode");
String cname=request.getParameter("cname");
String etype=request.getParameter("etype");
String sdate=request.getParameter("sdate");
int pack=Integer.parseInt(request.getParameter("pack"));
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","");
Statement st=con.createStatement();
out.println("<h3>Data Saved Successfully!</h3>");
String s="insert into prog7 values('"+sname+"','"+regno
+"','"+course+"','"+comb+"','"+mode+"','"+cname+"','"+etype+"','"+sdate+"',"+pack+");";
st.executeUpdate(s);
}
catch(Exception e)
{
//out.println("Insertion of data failed!");
out.println("<H3>Enter Valid Input!</H3>");
}
%>
</body>
</html>
No comments :
Post a Comment