0% found this document useful (0 votes)
9 views6 pages

Three-Tier Student Mark List App

The document describes creating a three-tier web application for maintaining a student marklist database using servlets and JDBC. It includes: 1) Creating a student database table to store information 2) A Java servlet that connects to the database, inserts student records, and retrieves and displays the records in an HTML table 3) An HTML form to enter student data and a button to view the marklist

Uploaded by

omprakkash1509
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views6 pages

Three-Tier Student Mark List App

The document describes creating a three-tier web application for maintaining a student marklist database using servlets and JDBC. It includes: 1) Creating a student database table to store information 2) A Java servlet that connects to the database, inserts student records, and retrieves and displays the records in an HTML table 3) An HTML form to enter student data and a button to view the marklist

Uploaded by

omprakkash1509
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

CS1404-INTERNET PROGRAMMING LAB

[Link]

INTERNET POGRAMMING LAB

11 THREE-TIER APPLICATION USING SERVLET-STUDENT MARKLIST DATE:21.9.10 Aim: Create a Three-tier application for maintaining Student Mark list Hardware requirements: Intel pentium Processor IV 128mb RAM Software requirements: Jdk1.6.0 Algorithm: 1. Create a data base for storing student information 2. Open the database using the JDBC ODBC Drivers using the methods of class 3. Using Connection, Statement , RecordSet classes select the record from the tables using suitable Query 4. Using the PrintWriter class create a decorative form to display the marklist 5. Fetch the records one by one from the record set and display them close the database connection

CS1404-INTERNET PROGRAMMING LAB

[Link]

THREE TIER APPLICATION-STUDENTS DATABASE HTML CODING: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "[Link] <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <title>Untitled Document</title> </head> <script> function validate() { [Link](); } </script> <body> <form name="form1" method="post" action ="[Link] <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td width="15%">Name</td> <td width="85%"><input name="name" type="text" id="name"></td> </tr> <tr> <td>Roll No </td> <td><input name="rollno" type="text" id="rollno"></td> </tr> <tr> <td>Mark1</td> <td><input name="mark1" type="text"></td> </tr> <tr> <td>Mark2</td> <td><input type="text" name="mark2"></td> </tr> <tr> <td>Mark3</td> <td><input type="text" name="mark3"></td> 2

CS1404-INTERNET PROGRAMMING LAB

[Link]

</tr> <tr> <td>Mark4</td> <td><input type="text" name="mark4"></td> </tr> <tr> <td>Mark5</td> <td><input type="text" name="mark5"></td> </tr> <tr> <td><input type="submit" name="Submit" value="insert"></td> <td><input type="button" name="Button" value="View All" onClick="[Link]='[Link]'"></td> </tr> </table> </form> </body></html> SERVLET CODING: import [Link].*; import [Link].*; import [Link].*; import [Link].*; public class insert extends HttpServlet { Connection conn=null; Statement stmt=null; ResultSet rs=null; public void init(ServletConfig config)throws ServletException { [Link](config); try { [Link]("[Link]"); conn = [Link]("jdbc:odbc:stud"); stmt = [Link](); } catch(Exception e) { [Link]("Driver not connected Error :"+e); } } 3

CS1404-INTERNET PROGRAMMING LAB

[Link]

public void doPost(HttpServletRequest request, HttpServletResponse res) throws ServletException,IOException { [Link]("text/html"); PrintWriter pw = [Link](); String name = [Link]("name"); int rollno = [Link]([Link]("rollno")); int mark1 = [Link]([Link]("mark1")); int mark2 = [Link]([Link]("mark2")); int mark3 = [Link]([Link]("mark3")); int mark4 = [Link]([Link]("mark4")); int mark5 = [Link]([Link]("mark5")); int total = mark1+mark2+mark3+mark4+mark5; double avg = total/5; try { [Link]("INSERT INTO student VALUES('"+ name+"','"+rollno+"','"+mark1+"','"+mark2+"','"+mark3+"','"+mark4+"','" +mark5+"','"+total+"','"+avg+"')"); rs=[Link]("select * from student"); [Link]("<HTML>"); [Link]("<HEAD><TITLE>STUDENT DATABASE</TITLE></HEAD>"); [Link]("<H2>STUDENT MRKLIST<H2>"); [Link]("<TABLE BORDER=1 cellspacing=0 cellpadding=0>"); [Link]("<TR> <TH>NAME</TH> </TH> <TH>ROLLNO</TH> <TH>MARK1</TH> <TH>MARK2</TH> <TH>MARK3</TH> <TH>MARK4</TH> <TH>MARK5</TH> <TH>TOTAL</TH> <TH>AVERAGE</TH> </TR> "); while([Link]()) { [Link]("<TR>"); [Link]("<TD>" + [Link]("name") + </TD>"); [Link]("<TD>" + [Link]("rollno") +</TD>"); [Link]("<TD>" +[Link]("mark1") +</TD>"); [Link]("<TD>" + [Link]("mark2") + /TD>"); [Link]("<TD>" + [Link]("mark3")+ /TD>"); [Link]("<TD>"+[Link]("mark4")+"</TD>"); [Link]("<TD>"+[Link]("mark5") +</TD>"); [Link]("<TD>" + [Link]("total") + "</TD>"); [Link]("<TD>" + [Link]("avg") + "</TD>"); [Link]("</TR>"); } [Link]("</TABLE>"); [Link]("</BODY>"); 4

CS1404-INTERNET PROGRAMMING LAB

[Link]

[Link]("</HTML>"); } catch(Exception e) { [Link]("SQLException :"+e); } } } DATABASE:

OUTPUT:

CS1404-INTERNET PROGRAMMING LAB

[Link]

RESULT: Thus the Java servlet program has been executed, displaying the Student marklist

You might also like