Filename:Stud22.html
<!-- 22. Program to read student info. and store into database -->
<html>
<head>
<title>Student Information</title>
</head>
<body>
<h3>Enter Student Details:<h3>
<form action="Stud22.jsp" method="POST" >
<table >
<tr><td>Name:</td><td><input type="text" name="sname" autofocus></td></tr>
<tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
<tr><td>Course:</td><td> <select name="course">
<option value="BCA">BCA</option>
<option value="BSc">BSc</option>
<option value="BA">BA</option>
</select> </td></tr>
<tr><td>Combination:</td><td> <select name="comb">
<option value="Computer Applications">Computer Applications</option>
<option value="PMCs">PMCs</option>
<option value="EMCs">EMCs</option>
<option value="HSP">HSP</option>
<option value="HEK">HEK</option>
</select> </td></tr>
<tr><td>Semester:</td><td> <select name="sem">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
<option value="VI">VI</option>
</select> </td></tr>
<tr><td>Sub1:</td><td><input type="text" name="sub1"></td></tr>
<tr><td>Sub2:</td><td><input type="text" name="sub2"></td></tr>
<tr><td>Sub3:</td><td><input type="text" name="sub3"></td></tr>
<tr><td>Sub4:</td><td><input type="text" name="sub4"></td></tr>
<tr><td>Sub5:</td><td><input type="text" name="sub5"></td></tr>
<tr><td><input type="submit" value="Save in Database" ></td>
<td><input type="reset" value="Reset" ></td></tr>
</table>
</body>
</html>
Filename:Stud22.jsp
<!-- 22. JSP Program to store Student Information in the Database. -->
<html>
<head>
<title>Student Information</title>
<%@page import="java.sql.*,java.util.*"%>
</head>
<body>
<%
String sname=request.getParameter("sname");
String regno=request.getParameter("regno");
String course=request.getParameter("course");
String comb=request.getParameter("comb");
String sem=request.getParameter("sem");
int sub1=Integer.parseInt(request.getParameter("sub1"));
int sub2=Integer.parseInt(request.getParameter("sub2"));
int sub3=Integer.parseInt(request.getParameter("sub3"));
int sub4=Integer.parseInt(request.getParameter("sub4"));
int sub5=Integer.parseInt(request.getParameter("sub5"));
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:stud22");
Statement st=con.createStatement();
try
{
out.println("<h3>Data Saved Successfully!</h3>");
String s="insert into stud22 values('"+sname+"','"+regno
+"','"+course+"','"+comb+"','"+sem+"',"+sub1
+","+sub2+","+sub3+","+sub4+","+sub5+");";
st.executeQuery(s);
}
catch(Exception e)
{
//out.println("Insertion of data failed!");
//out.println(e);
}
%>
</body>
</html>
<!-- 22. Program to read student info. and store into database -->
<html>
<head>
<title>Student Information</title>
</head>
<body>
<h3>Enter Student Details:<h3>
<form action="Stud22.jsp" method="POST" >
<table >
<tr><td>Name:</td><td><input type="text" name="sname" autofocus></td></tr>
<tr><td>Register Number:</td><td><input type="text" name="regno"></td></tr>
<tr><td>Course:</td><td> <select name="course">
<option value="BCA">BCA</option>
<option value="BSc">BSc</option>
<option value="BA">BA</option>
</select> </td></tr>
<tr><td>Combination:</td><td> <select name="comb">
<option value="Computer Applications">Computer Applications</option>
<option value="PMCs">PMCs</option>
<option value="EMCs">EMCs</option>
<option value="HSP">HSP</option>
<option value="HEK">HEK</option>
</select> </td></tr>
<tr><td>Semester:</td><td> <select name="sem">
<option value="I">I</option>
<option value="II">II</option>
<option value="III">III</option>
<option value="IV">IV</option>
<option value="V">V</option>
<option value="VI">VI</option>
</select> </td></tr>
<tr><td>Sub1:</td><td><input type="text" name="sub1"></td></tr>
<tr><td>Sub2:</td><td><input type="text" name="sub2"></td></tr>
<tr><td>Sub3:</td><td><input type="text" name="sub3"></td></tr>
<tr><td>Sub4:</td><td><input type="text" name="sub4"></td></tr>
<tr><td>Sub5:</td><td><input type="text" name="sub5"></td></tr>
<tr><td><input type="submit" value="Save in Database" ></td>
<td><input type="reset" value="Reset" ></td></tr>
</table>
</body>
</html>
Filename:Stud22.jsp
<!-- 22. JSP Program to store Student Information in the Database. -->
<html>
<head>
<title>Student Information</title>
<%@page import="java.sql.*,java.util.*"%>
</head>
<body>
<%
String sname=request.getParameter("sname");
String regno=request.getParameter("regno");
String course=request.getParameter("course");
String comb=request.getParameter("comb");
String sem=request.getParameter("sem");
int sub1=Integer.parseInt(request.getParameter("sub1"));
int sub2=Integer.parseInt(request.getParameter("sub2"));
int sub3=Integer.parseInt(request.getParameter("sub3"));
int sub4=Integer.parseInt(request.getParameter("sub4"));
int sub5=Integer.parseInt(request.getParameter("sub5"));
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con = DriverManager.getConnection("jdbc:odbc:stud22");
Statement st=con.createStatement();
try
{
out.println("<h3>Data Saved Successfully!</h3>");
String s="insert into stud22 values('"+sname+"','"+regno
+"','"+course+"','"+comb+"','"+sem+"',"+sub1
+","+sub2+","+sub3+","+sub4+","+sub5+");";
st.executeQuery(s);
}
catch(Exception e)
{
//out.println("Insertion of data failed!");
//out.println(e);
}
%>
</body>
</html>
No comments :
Post a Comment