BCA

WEB PROGRAMMING LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6

PART B

PROGRAM 7 PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 PROGRAM 15 . . .

instructions;

  • download mysql-connector 8.0.19.jar a jar for for class click here to download
  • copy this jar file into 'Apache-verXx/lib' folder ( path of tomcat apache)
  • befor run program 1.start mysql in bitnami servee , and create required database and table, for this question.datatbase is "mytestdb" and table is "studentplacement"
OUTPUT:
Question:
  • Your college wants to keep a record of student placements.
  • Design a user interface to accept.
  • Student name, Register number, Course, Combination,
  • Placement Mode (On campus, offcampus), Name of the company (or office), Employer Type (Private, Government), Selectiondate, Package.
  • The accepted data should be recorded in the database table (the choice of database management system is open except MS-Access).
  • Write a JSP program for the purpose. Verify every omission and errors in feeding the data.


db name:mytestdb


CREATE TABLE studentplacement
(
id int(5) auto_increment,
registernumber varchar(10),    
name varchar(50),    
course varchar(50),  
placememntmode varchar(50),  
employertype varchar(50),  
selectiondate varchar(50),  
package varchar(50), 
 PRIMARY KEY (id )    
);    

STUDENT PLACMENT DETAILS

STUDENT NAME:
Register Number:
Course
Placement Mode :
Name of the company:
Employer Type :
Selection Date :
Package :

PAGE 2: SERVER SIDE :

STUDENT INFORMATION IS STORED SUCCESSFULLY

STUDENT INFORMATION

register number1
student name raj
course bca
placememntmode oncampus
company IBM
employertype private
selectiondate 4/8/2021
package 6,00,000

file 1: programC7Client.html

 
 
 
 <html>
<head><title>STUDENT INFORMATION</title></head>
<body>

Question:
<ul>  <li>Your college wants to keep a record of student placements. </li>
<li>Design a user interface to accept. </li><li>
 Student name, 
Register number, 
Course, Combination, </li><li>
Placement Mode (On campus, offcampus),
 Name of the company (or office),
 Employer Type (Private, Government), 
Selectiondate, Package. </li><li>
The accepted data should be recorded in the database table (the choice of
database management system is open except MS-Access).</li><li>
 Write a JSP program for the purpose. Verify every omission and errors in feeding the data.</li><li>
</ul>


<form action="programC7Server.jsp" method="post">
<h1>STUDENT PLACMENT DETAILS</h1>

<table>
 

<tr><td>
<center>STUDENT NAME:</td><td><input type="text" name="studentname">

</td></tr>
<tr><td>
<center>Register Number:</td><td><input type="number" name="registernumber">

</td></tr>

<tr><td>
<center>Course</td><td><input type="text" name="course">

</td></tr>

<tr><td>
<center>Placement Mode :</td><td>
<select input type="text" name="placememntmode">
<option value="oncampus">on campus</option>
 <option value="offcampus">off campus</option> </select>

</td></tr>

<tr><td>
<center>Name of the company:</td><td><input type="text" name="company">

</td></tr>

<tr><td>
<center>Employer Type :</td><td> 
<select input type="text" name="employertype">
<option value="private">Private</option>
 <option value="government">Government</option> </select>

</td></tr>

<tr><td>
<center>Selection Date  :</td><td><input type="text" name="selectiondate">

</td></tr>

<tr><td>
<center>Package :</td><td><input type="text" name="package">

</td></tr>
<tr><td>


</td><td>

</td><td>
<tr><td>

<center><input type="submit" value="SUBMIT">


</td></tr>
</table>
</body>
</html>
 




file 1: programC7Server.jsp

 
 
 
 
  



<html>
<style>
table, th, td{
border: 1px solid black;}
</style>
<head><title>STUDENT INFORMATION</title>
<%@ page import="java.sql.*,java.util.*"%>
 
<%@ page import="java.io.*" %>
</head>
<body>
<h6>STUDENT INFORMATION IS STORED SUCCESSFULLY</h6>
<h1>STUDENT INFORMATION</h1>
<%

 


//int ID=Integer.parseInt(request.getParameter("pid"));



String studentname=request.getParameter("studentname");
String registernumber=request.getParameter("registernumber");
String course=request.getParameter("course");
String placememntmode=request.getParameter("placememntmode");
String company=request.getParameter("company");
String employertype=request.getParameter("employertype");
String selectiondate=request.getParameter("selectiondate");
String packagepr=request.getParameter("package");

 

out.print("<table>");
out.println("<tr><td>register number</td><td>"+registernumber+"</td></tr>");
out.println("<tr><td>student name </td><td>"+studentname+"</td></tr>");

out.println("<tr><td>course </td><td>"+course+"</td></tr>");

out.println("<tr><td>placememntmode </td><td>"+placememntmode+"</td></tr>");

out.println("<tr><td>company </td><td>"+company+"</td></tr>");
out.println("<tr><td>employertype </td><td>"+employertype+"</td></tr>");
out.println("<tr><td>selectiondate </td><td>"+selectiondate+"</td></tr>");

out.println("<tr><td>package </td><td>"+packagepr+"</td></tr>");
out.print("</table>");



 

try {
     

      String connectionURL = "jdbc:mysql://localhost:3306/mytestdb"; 
       Class.forName("com.mysql.jdbc.Driver") .newInstance();
       

           Connection connecion = DriverManager
                    .getConnection(connectionURL,"root","");
            

            
          PreparedStatement    p=connection.prepareStatement("insert into studentplacement         values('"+registernumber+"','"+studentname+"','"+course+"',
                                    '"+placememntmode+"','"+company+"','"+employertype+"','"+selectiondate+"','"+packagepr+"')");
              int rs=p.executeUpdate();
                        if(rs>0)
                        {
	                        out.print("DATA INSERTED SUCCESSFULLY");
                        }
                        else
                        {
	                        out.print(" NOT CONNECTED");
                        }
          

        
          
        if(!connection.isClosed())
          
        out.println("Successfully connected to " + "MySQL server using TCP/IP...");
        connection.close();
    }
    catch(Exception ex){
     
            out.println("Unable to connect to database.");
    }

%>


</body>
</html>