Professional Documents
Culture Documents
To Create A College Management System Using Servlets With JDBC Ex - No:2.3b Date
To Create A College Management System Using Servlets With JDBC Ex - No:2.3b Date
3b
Date:
Question:
Develop a web application using HTML &Servlets for the given scenario below:
(Required database tables implementation must be done)
Consider you need to create a module in the project College Management system. In your
module you need to create the option for new staff registration by getting the staffs Name,
employee no, qualification and designation from the admin. You have to include the facility to
store and maintain all the details in database table. To give the conformation to the admin about
new faculty registration, print the staffs registration details at the end of your module execution.
Implement your module.
Aim:
To create a module in the project College Management system and perform the given
operations.
Program:
Html:
</html>
<body align="center">
<br><a href="html1.html">1.Goto admin</a><br>
<a href="html2.html">2.Register</a>
<h></body></html>
<html><body>
<form action="http://localhost:8080/unit2.3_b_/ser" method="post">
<input type="submit" value="click to continue">
</form></body></html>
<HTML><BODY>
<p><h ALIGN="CENTER"><b><font size=5 style="color:lightgreen;">
INSERT STAFF DETAILS<br>
<FORM ACTION="http://localhost:8080/unit2.3_b_/ser1" METHOD="post">
Staff Name
Servlet:
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
PrintWriter pw;
pw = res.getWriter();
res.setContentType("text/html");
try{
String a;
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection
con=DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
Statement stmt=con.createStatement();
ResultSet re;
a="select * from college";
re=stmt.executeQuery(a);
String b,c,d,f,g,h,i;
pw.write("<html><body bgcolor='lightgreen'><table border='1'><tr><td>Staff
name</td><td>id</td><td>Qualification</td><td>destination</td>");
while(re.next())
{
b=re.getString("name"); c=re.getString("emp_no");
d=re.getString("qualification");f=re.getString("destination");
pw.write("</tr><tr><td>"+b+"</td><td>"+c+"</td><td>"+d+"</td><td>"+f+"</td></tr>");}
pw.write("</table></body></html>");}
catch(SQLException e)
{
System.out.println(e);
}
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.GenericServlet;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
public class ser1 extends GenericServlet
{
public void service(ServletRequest req,ServletResponse res) throws ServletException,
IOException
{
String a1=req.getParameter("name");
String a2=req.getParameter("no");
String a3=req.getParameter("q");
String a4=req.getParameter("d");
PrintWriter pw= res.getWriter();
res.setContentType("text/html");
try{
String a;
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection
con=DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
Statement stmt=con.createStatement();
a="insert into college values('"+a1+"','"+a2+"','"+a3+"','"+a4+"')";
stmt.execute(a);
pw.write("<html><body><br><br><br><br><font size=5;
style='color:orange;'><i><b><marquee>registered
successfully...</marquee></font></body></html>");
}catch(SQLException e){
System.out.println(e);
}
Output:
Result:
Thus the project College Management system was created and performed the given
operations successfully.