WEB TECH Lab Manual

Published on March 2017 | Categories: Documents | Downloads: 46 | Comments: 0 | Views: 424
of 64
Download PDF   Embed   Report

Comments

Content

www.vidyarthiplus.com

Ex. No. : 01 Date AIM: :

Creation of HTML pages with frames, links, tables and other tags

To create a simple webpage using HTML that includes all tags. ALGORITHM: 1. Write a HTML program in the notepad with the tags such as A. FRAMES With frames, you can display more than one HTML document in the same browser window. Each HTML document is called a frame, and each frame is independent of the others. The Frameset Tag The <frameset> tag defines how to divide the window into frames. The Frame Tag The <frame> tag defines what HTML document to put into each frame. Example: <frameset cols="25%, 75 %"> <frame src="frame_a.htm"> <frame src="frame_b.htm"> </frameset> Tags and their Description: <frameset> Defines a set of frames <frame> Defines a sub window (a frame)
www.vidyarthiplus.com

www.vidyarthiplus.com

B. LINKS A hyperlink is a reference (an address) to a resource on the web. Example: <a href="http://www.w3schools.com/">Visit W3Schools!</a> The href Attribute The href attribute defines the link "address". The target Attribute The target attribute defines where the linked document will be opened. Tag and its Description: <a> Defines an anchor C. TABLES Tables are defined with the <table> tag. A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td> tag). The letters td stands for "table data," which is the content of a data cell. Example: <table border="1"> <tr> <td>Row 1, cell 1</td> <td>Row 1, cell 2</td> </tr> </table> Tags and their Description: <Table> Defines a table <th> Defines a table header <tr> Defines a table row <td> Defines a table cell 2. Use appropriate tags to apply the background colors and desired styles as Required and save the file with .html extension.

www.vidyarthiplus.com

www.vidyarthiplus.com

3. Run the program in the Web Browser. PROGRAM: Home.html <html> <head> <title>Home</title> </head> <frameset rows="25%,*"> <frame src="frame1.html"> <frameset cols="25%,*"> <frame src="frame2.html" name="f2"> <frame src="frame3.html" name="f3"> </frameset> </html> Frame1.html <html> <head><title>frame1</title> </head> <body bgcolor="blue"> <h1 style="color.green;font-size:15pt"> <marquee bgcolor="#cccccc" loop="-1" scrollamount="6" width="100%"> THIRUVALLUVAR COLLEGE OF ENGINEERING AND TECHNOLOGY </marquee> </h1> </body> </html> Frame2.html <html> <head><title>frame2</title> <style type="text/css"> h1 { font-size:25pt;color:pink;
www.vidyarthiplus.com

www.vidyarthiplus.com

} </style> </head> <body bgcolor="red"> <h1>click the link</h1> <a href="intro.html" target=f3>Introduction</a><br> <a href="dept.html" target=f3>Departments</a><br> <a href="ad.html" target=f3>ADDRESS</a><br> <a href="feed.html" target=f3>Feedback</a><br> <a href="gall.html" target=f3>Gallery</a><br> </body> </html Frame3.html <html> <head><title>1st page</title> <link rel="stylesheet" type="text/css" href="C:\Documents and Settings\Administrator\Desktop\ab\css1.css"/> </head> <body bgcolor="tan"> <h2> <center>YOU ARE IN HOME PAGE</center></h2> </body> </html> Intro.html <html> <head><title>intro</title> </head> <body bgcolor="black"> <font color=red> <p> Welcome to Thiruvalluvar College of Engineering and Technology Affiliated to Anna University<br> <br>

www.vidyarthiplus.com

www.vidyarthiplus.com

“Thiruvalluvar College of Engineering and Technology resolves to mould a human task force useful to the society through transparent methods that lead to continuous improvement of the resources and state-of-the-art methodologies conforming to recognized standards.” </p> </font> </body> </html> Ad.html <html> <head><title>ADDRESS</title> </head> <body bgcolor="black"> <p> <font color=red> Name:Thiruvalluvar College of Engineering and Technology<br> Location:Vandavasi<br> Contact No:04183-221444<br> Website: www.google.co.in<br> </font> </p> </body> </html> Dept.html <html> <head><title>Departments</title> </head> <body> <div align="center"> <table border=2> <tr> <th>Dept code</th> <th>Dept name</th> </tr>
www.vidyarthiplus.com

www.vidyarthiplus.com

<tr> <td>01</td> <td>CSE</td> </tr> <tr> <td>02</td> <td>ECE</td> </tr> <tr> <td>03</td> <td>EEE</td> </tr> <tr> <td>04</td> <td>IT</td> </tr> <tr> <td>05</td> <td>MECH</td> </tr> <tr> <td>06</td> <td>AERO</td> </tr> </table> </div> </body> </html> Feed.html <html> <head><title>feed</title> </head> <body bgcolor="black"> <p> <font color=green>
www.vidyarthiplus.com

www.vidyarthiplus.com

To give your feedback mail to [email protected] </font> </p> </body> </html> Gall.html <html> <head><title>gall</title> </head> <body bgcolor="pink"> <p> <font color=blue> College Front View</font> </p> <img src="file:///d:/google.JPG" height="300" width="400"/> </body> </html>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

www.vidyarthiplus.com

www.vidyarthiplus.com

www.vidyarthiplus.com

www.vidyarthiplus.com

RESULT: Thus the HTML pages are created using frames, links, tables and other tags and have been successfully executed.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 2 Date: Aim:

APPLYING STYLE TO AN HTML PAGE USING CSS

To create an html page, and to apply style formatting using external Cascading Style Sheet. Algorithm: Step 1: Step 2: Step 3: Step 4: Step 5: Step 6: Step 7: Start the program. Create an html page. Create an external CSS (Cascading Style Sheet). Link the external style sheet page with the main html page. Load the main page. The style formatting will be applied to the main html page. Stop the program.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: Style.html <html> <head> <style type="text/css"> .class1 A:link {text-decoration: none} .class1 A:visited {text-decoration: none} .class1 A:active {text-decoration: none} .class1 A:hover {text-decoration: underline; color: red;} .class2 A:link {text-decoration: underline overline} .class2 A:visited {text-decoration: underline overline} .class2 A:active {text-decoration: underline overline} .class2 A:hover {text-decoration: underline; color: green;} </style> <title>My first styled page</title> <link rel="stylesheet"href="mystyle.css"> <style type="text/css"> <!-.style2 {font-family: Verdana, Arial, Helvetica, sans-serif} --> </style> </head> <body> <!--site navigation menu--> <span class="class2"> <ul class="navbar"> <li><a href="home.html">HOME</a> <li><a href="home.html">Department</a> <li><a href="home.html">Contact us</a> </ul> </span> <!--Main content--> <h1>My first Internal styled page</h1> <p> Thiruvalluvar College of Engineering and Technology resolves to mould a human task force useful to the society through transparent methods
www.vidyarthiplus.com

www.vidyarthiplus.com

that lead to continuous improvement of the resources and state-of-the-art methodologies conforming to recognized standards. <!--sign and date the page--> <p><address class="style2" >M.E(CSE) <br> 31-06-2011</address></p> </body> </html> Mystyle.html: <html> <head> <title>My first styled page</title> <link rel="stylesheet"href="mystyle.css"> </head> <body> <!--site navigation menu--> <ul class="navbar"> <li><a href="About.html">About us</a> <li><a href="home.html">Department</a> <li><a href="home.html">Contact us</a> </ul> <!--Main content--> <h1>My first External styled page</h1> <p> THIRUVALLUVAR COLLEGE OF ENGINEERING AND TECHNOLOGY <BR> ARUNACHAL CITY<br> VANDAVASI<br> <p> An ISO 9001:2008 institution<br> NBA Accredited<br> <!--sign and date the page--> <p><address>December 28th <br> Dept. of I.T.</address> </body> </html>
www.vidyarthiplus.com

www.vidyarthiplus.com

/* CSS Document */ BODY { PADDING-LEFT: 11em; COLOR: purple; FONT-FAMILY: Georgia, "Times New Roman", Times, serif; BACKGROUND-COLOR: #d8da3d } UL.navbar { PADDING-RIGHT: 0px; PADDING-LEFT: 0px; LEFT: 1em; PADDING-BOTTOM: 0px; MARGIN: 0px; WIDTH: 9em; PADDING-TOP: 0px; LIST-STYLE-TYPE: none; POSITION: absolute; TOP: 2em } H1 { FONT-FAMILY: Helvetica, Geneva, Arial, SunSans-Regular, sans-serif } UL.navbar LI { BORDER-RIGHT: 1em solid; PADDING-RIGHT: 0px; PADDING-LEFT: 0px; BACKGROUND: white; PADDING-BOTTOM: 0.3em; MARGIN: 0.5em 0px; PADDING-TOP: 0.3em }
www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus an html page is created and style formatting is applied using external Cascading Style Sheet.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 3(A) Date :

Client Side Programming Java script for Displaying and Comparing Date

AIM: To write a Java script program for displaying and comparing two dates.

ALGORITHM: Java script program for displaying date 1. Create a variable for DATE object as shown below, var currentTime = new Date() 2. Obtain the current date from it using getDate() as shown below, Var d=currentTime.getDate() 3 Display the value of d. Java script program for comparing two dates 1. Get two dates to be compared from the user in string format. 2. Convert the obtained string into DATE objects as shown below, var todate = new Date(todatestring); var fromdate = new Date(fromdatestring); 3. Compare these two dates using ‘<’ operator.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: <html> <script> function Compare() { if (document.frmTest.startDate.value > document.frmTest.endDate.value){ alert ("Start Date is greater"); } if (document.frmTest.startDate.value < document.frmTest.endDate.value){ alert ("End Date is greater"); } if (document.frmTest.startDate.value == document.frmTest.endDate.value){ alert ("Dates are the same"); } } </script> <body> <form name="frmTest"> Start Date: <b><input type="text" name="startDate" size="14"></b> <br> <br> End Date: <b><input type="text" name="endDate" size="14"></b> <a href="javascript:Compare();">Compare</a> </form> </body> </html>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus the program for displaying and comparing two dates has been completed successfully and output is verified.

www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 3.b Date :

Client Side Programming Form Validation

AIM: To write a Java script program for Form Validation including text field, radio buttons, check boxes, list box and other controls.

ALGORITHM: Client Side Programming - Form validation 1. Create a form by including all the elements of java script. Ex: <input type=”button” value=”OK”> <input type=”checkbox” name=”c”> <input type=”text”> etc.

2. Create a button in such a way that when the button is clicked the form has to be validated (i.e. it has to check whether all fields in the form are filled and the data entered are valid).

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-88591"> </head> <body> <b><font face="Verdana"><font size=+1>Form Validation Example: Feedback Form</font></font></b> <br><script LANGUAGE="JavaScript"> <!-function ValidateForm(form){ ErrorText= ""; if (form.username.value == "") {ErrorText= "\nPlease enter your name"} if ((form.email.value == "" || form.email.value.indexOf('@', 0) == -1) || form.email.value.indexOf('.') == -1){ ErrorText+= "\nPlease enter a proper value for your email"} if (form.feedback.value == "") {ErrorText+= "\nPlease enter your feedback"} if (ErrorText!= "") { alert("Error :" + ErrorText); return false; } if (ErrorText= "") { form.submit() } ErrorText= ""; if ( ( form.gender[0].checked == false ) && ( form.gender[1].checked == false ) ) { alert ( "Please choose your Gender: Male or Female" ); return false; } if (ErrorText= "") { form.submit() } ErrorText= ""; if ( form.age.selectedIndex == 0 ) { alert ( "Please select your Age." ); return false; } if (ErrorText= "") { form.submit() }
www.vidyarthiplus.com

www.vidyarthiplus.com

alert ( "Thank u" ) } --> </script> <br><form name="feedback" action="mailto:[email protected]" method=post> <dl> <dt> <font face="Verdana"> <pre> Please enter the following(To test form validation, skip entering one of the fields and click 'Submit' button): </pre> </font> <font face="Verdana">Name: &nbsp;</font><input type="text" value="" name="username" size=30></dt><br> <br><dt> <font face="Verdana">E-mail: &nbsp;</font><input type="text" value="" name="email" size=30></dt><br> <br><dt><font face="Verdana">Your Gender:</font> <input type="radio" name="gender" value="Male"> Male <input type="radio" name="gender" value="Female"> Female </dt><dt> </dt> <br> <font face="Verdana, Arial, Helvetica, sans-serif">Your Age</font>: <select name="age"> <option value="">Please Select an Option:</option> <option value="0-18 years">0-18 years</option> <option value="18-30 years">18-30 years</option> <option value="30-45 years">30-45 years</option> <option value="45-60 years">45-60 years</option> <option value="60+ years">60+ years</option> </select> <br> <br><font face="Verdana">Feedback:</font> <dt><textarea rows=7 cols=60 name="feedback"></textarea></dt> </dl> <input type="button" name="SubmitButton" value="Submit" onClick="ValidateForm(this.form)">
www.vidyarthiplus.com

www.vidyarthiplus.com

<input type="reset" value="Reset"> </form> <pre><font face="Verdana"><font size=+0>&nbsp; &nbsp;</font></font> </pre>

</form> </body> </html>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus the Java script program for Form Validation including text field, radio buttons, check boxes, list box and other controls has been successfully written and output is verified.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 04 Date:

Online Applications using jsp

AIM: To develop a Online Applications for displaying student’s mark list using java server pages and MS-Access database.

ALGORITHM: Step 1: Start the program. Step 2: Create a MS-Access database table named student for storing student’s marks. Step 3: Create an html form for entering the register number of the student. Step 4: Open control panel and make the database connectivity settings. Step 5: Create a JSP coding for processing the student’s marks from the database. Step 6: Deploy the JSP and the html page in the Netbeans 6.8 IDE to create the application package. Step 7: Run the application in the IDE. Step 8: The student’s mark list for the corresponding register number will be displayed. Step 9:Stop the program.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: mark.html <html> <body bgcolor=#779966 text=black> <center><font color=blue><h2>LOGIN FORM</h2></font></center> <form method =get action="http://localhost:8084/marklist/mark.jsp"> <table align=center border=0 bgcolor=#777799> <tr><td>REG NUMBER</td><td>:</td><td><input type=text name=login value=""> </td> </table><br><br><center> <input type=submit value=SUBMIT> <input type=Reset value=RESET></center> </form> </body> </html> mark.jsp <%@ page session="false" %> <%@page import="java.sql.*" %> <% try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("JDBC driver loaded"); } catch(ClassNotFoundException e) { System.out.println(e.toString()); } %> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF8"> <title>Display All Users</title>
www.vidyarthiplus.com

www.vidyarthiplus.com

</head> <body bgcolor="#779966"> <center> <br> <h2> MARK LIST </h2> <br> <hr/> <br> <table border="3"> <tr> <th>CNS</th> <th>W T</th> <th>NPM</th> <th>DWM</th> <th>E S</th> <th>OAD</th> </tr> <% int reg=Integer.parseInt(request.getParameter("login")); String sql="select *from student"; try { Connection con=DriverManager.getConnection("jdbc:odbc:student"); Statement s=con.createStatement(); ResultSet rs=s.executeQuery(sql); while(rs.next()) { out.println("<tr>"); out.println("<td>"+ rs.getString(2)+"</td>"); out.println("<td>"+rs.getString(3)+"</td>"); out.println("<td>" +rs.getString(4)+"</td>"); out.println("<td>"+rs.getString(5)+"</td>"); out.println("<td>"+rs.getString(6)+"</td>"); out.println("<td>"+rs.getString(7)+"</td>"); out.println("</tr>");
www.vidyarthiplus.com

www.vidyarthiplus.com

} rs.close(); s.close(); con.close(); } catch(SQLException e){} catch(Exception e){ } %> </table> </center> </body> </html>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus a 3-tier application for displaying student’s mark list using java server pages and MS-Access database has been developed.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 05 Date :

Servlet program using HTTP Servlet

AIM: To write a servlet program using HTTP Servlet. ALGORITHM: 1. Create a HTML page including some form elements. 2. Inside the <form> tag, for the action attribute specify the full path name of the .jsp file. 3. Create a .java file that imports javax.http.servlet.*; 4. Create a class that extends HttpServlet. 5. This will request some information by filling out a form containing a link to a servlet when the Submit button is clicked. 6. The server locates the requested servlet 7. Define the doPost function to process the data obtained from the HTML file. 8. The servlet then gathers the information needed to satisfy the user's request and constructs a Web page containing the information. 9. That Web page is then displayed on the user's browser

www.vidyarthiplus.com

www.vidyarthiplus.com

Program: <html> <head> <title> online exam </title> </head> <body> <form action="http://localhost:8080/examples/servlet/source_servlet" method="get"> <h3> 1.Who invented mainframe system? </h3> <input type="radio" name="s1" value="IBM"> ibm <br> <input type="radio" name="s1" value="MICROSOFT"> microsoft <br> <input type="radio" name="s1" value="INFOSYS"> infosys <br> <input type="radio" name="s1" value="CISCO"> cisco <br> <h3> 2.What is the capital of Sri Lanka? </h3> <input type="radio" name="s2" value="MADRID"> madrid <br> <input type="radio" name="s2" value="COLOMBO"> colombo <br> <input type="radio" name="s2" value="DELHI"> delhi <br> <input type="radio" name="s2" value="MOSCOW"> moscow <br> <h3> 3.What is the national game of India? </h3> <input type="radio" name="s3" value="HOCKEY"> hockey <br> <input type="radio" name="s3" value="CRICKET">cricket <br> <input type="radio" name="s3" value="FOOTBALL"> football <br> <input type="radio" name="s3" value="VOLLEYBALL"> volleyball <br> <h3> 4.What is the NATO name of SUKHOI jets? </h3> <input type="radio" name="s4" value="FLANKERS"> flankers <br> <input type="radio" name="s4" value="FOXBOAT"> foxboat <br> <input type="radio" name="s4" value="FISHBOAT"> fishboat <br> <input type="radio" name="s4" value="FOXTROT"> foxboat <br> <h3> 5.What was the first name of graphical browser? </h3> <input type="radio" name="s5" value="NETSCAPE"> netscape <br> <input type="radio" name="s5" value="IE"> ie <br> <input type="radio" name="s5" value="MOZILLA"> mozilla <br> <input type="radio" name="s5" value="OPERA"> opera <br> <input type="submit" value="submit"> </form> </body> </html>
www.vidyarthiplus.com

www.vidyarthiplus.com

//Online examination import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.net.*; public class source_servlet extends HttpServlet { public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException { response.setContentType("text/html"); PrintWriter out=response.getWriter(); BufferedReader br=request.getReader(); int score=0; String str; try { str=request.getParameter("s1"); if(str.equals("IBM")) score++; str=request.getParameter("s2"); if(str.equals("COLOMBO")) score++; str=request.getParameter("s3"); if(str.equals("HOCKEY")) score++; str=request.getParameter("s4"); if(str.equals("FLANKERS")) score++; str=request.getParameter("s5");
www.vidyarthiplus.com

www.vidyarthiplus.com

if(str.equals("MOZILLA")) score++; out.println("<html><head><title>result</title></head><body> Your score"); out.println(Integer.toString(score)+"</body></html>"); out.flush(); out.close(); } catch(Exception e) {} } }

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus servlet program using http servlet has been completed successfully and thus output is verified.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 06 Date:

Online application with data access

AIM: To develop a Online application with data access for displaying student’s mark list using java servlet and MS-Access database.

ALGORITHM: Step 1: Start the program. Step 2: Create a MS-Access database table named student for storing student’s marks. Step 3: Create an html form for entering the register number of the student. Step 4: Open control panel and make the database connectivity settings. Step 5: Create a servlet for processing the student’s marks from the database. Step 6:Deploy the servlet and the html page in the Netbeans 6.8 IDE to create the application package. Step 7: Run the application in the IDE. Step 8:The student’s mark list for the corresponding register number will be displayed. Step 9:Stop the program.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: mark.html <html> <body bgcolor=#779966 text=black> <center><font color=blue><h2>LOGIN FORM</h2></font></center> <form method =get action="http://localhost:8084/marklist/Student"> <table align=center border=0 bgcolor=#777799> <tr><td>REG NUMBER</td><td>:</td><td><input type=text name=login value=""> </td> </table><br><br><center> <input type=submit value=SUBMIT> <input type=Reset value=RESET></center> </form> </body> </html>

www.vidyarthiplus.com

www.vidyarthiplus.com

Student.java import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; public class Student extends HttpServlet { int m1,m2,m3,m4,m5,m6; public void doGet(HttpServletRequest r,HttpServletResponse rs)throws IOException,ServletException { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con=DriverManager.getConnection("jdbc:odbc:student"); Statement st=con.createStatement(); ResultSet res; String query="select *from student"; res=st.executeQuery(query); rs.setContentType("text/html"); PrintWriter out=rs.getWriter(); out.println("<html><body>"); int reg1=Integer.parseInt(r.getParameter("login")); int valid=0; while(res.next()) { if(res.getInt(1)==reg1) { valid=1; m1=res.getInt(2); m2=res.getInt(3); m3=res.getInt(4); m4=res.getInt(5); m5=res.getInt(6); m6=res.getInt(7); break;
www.vidyarthiplus.com

www.vidyarthiplus.com

} } if(valid==0) { out.println("not valid RegNo"); } else { out.println("<html><body bgcolor=#ccbbaa"); out.println("<p>&nbsp;</p>"); out.println("<center><font color=blue><h2>GOOGLE </h2></font></center>"); out.println("<p align=center>"); out.println("MARK1<input type=text name=mark1 value="+m1+">"); out.println("MARK2<input type=text name=mark2 value="+m2+">"); out.println("<p>"); out.println("<p align=center>"); out.println("MARK3<input type=text name=mark3 value="+m3+">"); out.println("MARK4<input type=text name=mark4 value="+m4+">"); out.println("<p>"); out.println("<p align=center>"); out.println("MARK5<input type=text name=mark5 value="+m5+">"); out.println("MARK6<input type=text name=mark6 value="+m6+">"); int tot1; double avg1; tot1=m1+m2+m3+m4+m5+m6; avg1=((tot1)/6.0); out.println("<hr>"); out.println("<p>&nbsp;</p>"); out.println("<p>&nbsp;</p>"); out.println("<p align=center>"); out.println("TOTAL<input type=text name=total value="+tot1+">"); out.println("AVERAGE<input type=text name=avg value="+avg1+">"); out.println("<p>"); out.println("</body></html>"); } }
www.vidyarthiplus.com

www.vidyarthiplus.com

catch(SQLException e) { System.out.println(e); } catch(ClassNotFoundException e) { System.out.println(e); } } }

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

www.vidyarthiplus.com

www.vidyarthiplus.com

RESULT: Thus a 3-tier application for displaying student’s mark list using java servlet and MS-Access database has been successfully developed.

www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 07 Date :

Creation of XML document

AIM: To write a XML program for creating a cd catalog.

ALGORITHM: 1. Create a .xml file with the following header, <?xml version=”1.0”?> 2. Include all the description of the CDs inside the <CATALOG> tag. 3. For each CD create a separate tag within the parent tag <CATALOG>which includes item title artist country company price and year. 4. Call the CSS file in which the format has been specified. 5. Run the XML program.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: cd_catalog_css.xml <?xml version="1.0" encoding="ISO-8859-1"?> <!-- Edited by XMLSpy® --> <?xml-stylesheet type="text/css" href="cd_catalog.css"?> <CATALOG> <CD> <TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>Bonnie Tyler</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS Records</COMPANY> <PRICE>9.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <TITLE>Greatest Hits</TITLE> <ARTIST>Dolly Parton</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>RCA</COMPANY> <PRICE>9.90</PRICE> <YEAR>1982</YEAR> </CD> <CD> <TITLE>Still got the blues</TITLE> <ARTIST>Gary Moore</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Virgin records</COMPANY> <PRICE>10.20</PRICE>
www.vidyarthiplus.com

www.vidyarthiplus.com

<YEAR>1990</YEAR>

</CD> <CD> <TITLE>Eros</TITLE> <ARTIST>Eros Ramazzotti</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>BMG</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD> <TITLE>One night only</TITLE> <ARTIST>Bee Gees</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>10.90</PRICE> <YEAR>1998</YEAR> </CD> <CD> <TITLE>Sylvias Mother</TITLE> <ARTIST>Dr.Hook</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>CBS</COMPANY> <PRICE>8.10</PRICE> <YEAR>1973</YEAR> </CD> <CD> <TITLE>Maggie May</TITLE> <ARTIST>Rod Stewart</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Pickwick</COMPANY> <PRICE>8.50</PRICE> <YEAR>1990</YEAR> </CD> <CD>
www.vidyarthiplus.com

www.vidyarthiplus.com

<TITLE>Romanza</TITLE> <ARTIST>Andrea Bocelli</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>10.80</PRICE> <YEAR>1996</YEAR> </CD>

<CD> <TITLE>When a man loves a woman</TITLE> <ARTIST>Percy Sledge</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Atlantic</COMPANY> <PRICE>8.70</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Black angel</TITLE> <ARTIST>Savage Rose</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Mega</COMPANY> <PRICE>10.90</PRICE> <YEAR>1995</YEAR> </CD> <CD> <TITLE>1999 Grammy Nominees</TITLE> <ARTIST>Many</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Grammy</COMPANY> <PRICE>10.20</PRICE> <YEAR>1999</YEAR> </CD> <CD> <TITLE>For the good times</TITLE> <ARTIST>Kenny Rogers</ARTIST> <COUNTRY>UK</COUNTRY>
www.vidyarthiplus.com

www.vidyarthiplus.com

<COMPANY>Mucik Master</COMPANY> <PRICE>8.70</PRICE> <YEAR>1995</YEAR> </CD> <CD> <TITLE>Big Willie style</TITLE> <ARTIST>Will Smith</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>9.90</PRICE> <YEAR>1997</YEAR> </CD> <CD>

<TITLE>Tupelo Honey</TITLE> <ARTIST>Van Morrison</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Polydor</COMPANY> <PRICE>8.20</PRICE> <YEAR>1971</YEAR> </CD> <CD> <TITLE>Soulsville</TITLE> <ARTIST>Jorn Hoel</ARTIST> <COUNTRY>Norway</COUNTRY> <COMPANY>WEA</COMPANY> <PRICE>7.90</PRICE> <YEAR>1996</YEAR> </CD> <CD> <TITLE>The very best of</TITLE> <ARTIST>Cat Stevens</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Island</COMPANY> <PRICE>8.90</PRICE> <YEAR>1990</YEAR>
www.vidyarthiplus.com

www.vidyarthiplus.com

</CD> <CD> <TITLE>Stop</TITLE> <ARTIST>Sam Brown</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>A and M</COMPANY> <PRICE>8.90</PRICE> <YEAR>1988</YEAR> </CD> <CD> <TITLE>Bridge of Spies</TITLE> <ARTIST>T`Pau</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Siren</COMPANY> <PRICE>7.90</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Private Dancer</TITLE> <ARTIST>Tina Turner</ARTIST> <COUNTRY>UK</COUNTRY> <COMPANY>Capitol</COMPANY> <PRICE>8.90</PRICE> <YEAR>1983</YEAR> </CD> <CD> <TITLE>Midt om natten</TITLE> <ARTIST>Kim Larsen</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Medley</COMPANY> <PRICE>7.80</PRICE> <YEAR>1983</YEAR> </CD> <CD> <TITLE>Pavarotti Gala Concert</TITLE> <ARTIST>Luciano Pavarotti</ARTIST> <COUNTRY>UK</COUNTRY>
www.vidyarthiplus.com

www.vidyarthiplus.com

<COMPANY>DECCA</COMPANY> <PRICE>9.90</PRICE> <YEAR>1991</YEAR> </CD> <CD> <TITLE>The dock of the bay</TITLE> <ARTIST>Otis Redding</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Atlantic</COMPANY> <PRICE>7.90</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Picture book</TITLE> <ARTIST>Simply Red</ARTIST> <COUNTRY>EU</COUNTRY> <COMPANY>Elektra</COMPANY> <PRICE>7.20</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Red</TITLE> <ARTIST>The Communards</ARTIST>

<COUNTRY>UK</COUNTRY> <COMPANY>London</COMPANY> <PRICE>7.80</PRICE> <YEAR>1987</YEAR> </CD> <CD> <TITLE>Unchain my heart</TITLE> <ARTIST>Joe Cocker</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>EMI</COMPANY> <PRICE>8.20</PRICE> <YEAR>1987</YEAR>
www.vidyarthiplus.com

www.vidyarthiplus.com

</CD> </CATALOG> cd_catalog.css <style> CATALOG { background-color: #ffffff; width: 100%; } CD { display: block; margin-bottom: 30pt; margin-left: 0; } TITLE { color: #FF0000; font-size: 20pt; } ARTIST { color: #0000FF; font-size: 20pt; } COUNTRY,PRICE,YEAR,COMPANY { display: block; color: #000000; margin-left: 20pt; } </style>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus the XML program for creating cd catalog has been successfully completed and output is verified.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 08 Date :

XML document and DTD

AIM: To write a XML program and DTD for a document.

ALGORITHM: 1. Create the XML document using <?xml version="1.0" encoding="ISO-8859-1"?> tag as the initial tab. 2. Create another CSS document which displays the xml document details into HTML format on the browser. 3. Give appropriate style in the CSS document. 4. Create the .xsd file for the xml file that is created. 5. In the .xsd file define the parent tag, the child tags, its type and all the attributes inside the schema tag. 6. Invoke xml file from your browser.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: <?xml version="1.0" ?> <!DOCTYPE note [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <message>Don't forget to buy grocery things </message> </note>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT: Thus the XML program and DTD for creating a Ship order has been Completed successfully and output is verified.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No. : 9 Date :

Parsing an XML document using DOM and SAX Parsers

AIM: To write a program that parses an XML document using DOM and SAX parsers. ALGORITHM: 1. Create a .xml file that has to be parsed. 2. Using DOM parser Get a document builder using document builder factory and parse the xml file to create a DOM object Get a list of employee elements from the DOM For each employee element get the id, name, age and type. Create an employee value object and add it to the list. At the end iterate through the list and print the employees to verify we parsed it right. 3. Using SAX Parser Create a Sax parser and parse the xml In the event handler create the employee object Print out the data

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: DOM: Student.xml <?xml version="1.0"?> <student> <Roll_No>10</Roll_No> <Personal_Info> <Name>parth</Name> <Address>pune</Address> <Phone>1234567890</Phone> </Personal_Info> <Class>Second</Class> <Subject>Maths</Subject> <Marks>100</Marks> <Roll_No>20</Roll_No> <Personal_Info> <Name>AnuRadha</Name> <Address>Bangalore</Address> <Phone>90901233</Phone> </Personal_Info> <Class>Fifth</Class> <Subject>English</Subject> <Marks>90</Marks> <Roll_No>30</Roll_No> <Personal_Info> <Name>Anand</Name> <Address>Mumbai</Address> <Phone>90901256</Phone> </Personal_Info> <Class>Fifth</Class> <Subject>English</Subject> <Marks>90</Marks> </student>

www.vidyarthiplus.com

www.vidyarthiplus.com

Parse.java import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; public class Parse { public static void main(String[] arg) { try { System.out.println("enter the name of xml document"); BufferedReader input=new BufferedReader(new InputStreamReader(System.in)); String file_name=input.readLine(); File fp=new File(file_name); if(fp.exists()) { try { DocumentBuilderFactory Factory_obj=DocumentBuilderFactory.newInstance(); DocumentBuilder builder=Factory_obj.newDocumentBuilder(); InputSource ip_src=new InputSource(file_name); Document doc=builder.parse(ip_src); System.out.println(file_name+" is well-formed!"); } catch(Exception e) { System.out.println(file_name+" isn't well-formed!"); System.exit(1); } } else { System.out.print("file not found!"); }
www.vidyarthiplus.com

www.vidyarthiplus.com

} catch(IOException ex) { ex.printStackTrace(); } }} SAX: EmployeeDetail.xml: <?xml version="1.0"?> <EmployeeDetail> <Employee> <Emp_id>E-001</Emp_id> <Emp_Name>revathy</Emp_Name> <Emp_E-mail>[email protected]</Emp_E-mail> </Employee> <Employee> <Emp_id>E-002</Emp_id> <Emp_Name>vinod</Emp_Name> <Emp_E-mail>[email protected]</Emp_E-mail> </Employee> <Employee> <Emp_id>E-001</Emp_id> <Emp_Name>deepak</Emp_Name> <Emp_E-mail>[email protected]</Emp_E-mail> </Employee> </EmployeeDetail>

www.vidyarthiplus.com

www.vidyarthiplus.com

SAXParserCheck.java: import org.xml.sax.*; import org.xml.sax.helpers.*; import java.io.*; public class SAXParserCheck { public static void main(String[]args)throws IOException { BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); System.out.print("enter XML file name :"); String xmlfile=bf.readLine(); SAXParserCheck par=new SAXParserCheck(xmlfile); } public SAXParserCheck(String str) { try { File file=new File(str); if(file.exists()) { XMLReader reader=XMLReaderFactory.createXMLReader(); reader.parse(str); System.out.println(str+" is well-formed!"); } else { System.out.println("File not found:"+str); } } catch(SAXException sax)
www.vidyarthiplus.com

www.vidyarthiplus.com

{ System.out.println(str+" isn't well-formed"); } catch(IOException io) { System.out.println(io.getMessage()); } } }

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT: DOM :

SAX:

RESULT: Thus the program that parses an XML document using DOM and SAX parsers has been completed successfully and the output is verified.
www.vidyarthiplus.com

www.vidyarthiplus.com

Ex. No : 10 Date :

Open Source Environment - PHP

AIM To Sample web application development in the open source environment ALGORITHM:

1. Install the wamp server. 2. Start all the service in wamp server. 3. Create the new project using PHP installation package. 4. Create new folder in www directory. 5. Create and connect Mysql. 6. Execute the program in the Local host.

www.vidyarthiplus.com

www.vidyarthiplus.com

PROGRAM: Index.html <html> <body> <form action="insert.php" method="post"> <center><h1>PHP-OPEN SOURCE ENVIRONMENT</h1></center> <center><b>Firstname:</b> <input type="text" name="firstname" /><br><br> <b>Lastname:</b> <input type="text" name="lastname" /><br><br> <b>Age:</b><input type="text" name="age" /><br><br> <input type="submit" /></center> </form> </body> </html> Insert.php <?php $con = mysql_connect("localhost","root",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("sample", $con); $sql="INSERT INTO Persons (FirstName, LastName, Age) VALUES ('$_POST[firstname]','$_POST[lastname]','$_POST[age]')";

www.vidyarthiplus.com

www.vidyarthiplus.com

if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } echo "<h1>1 record added"; mysql_close($con) ?>

www.vidyarthiplus.com

www.vidyarthiplus.com

OUTPUT:

RESULT:
www.vidyarthiplus.com

www.vidyarthiplus.com

The Sample web application using PHP, MYSQL & wamp server as an open source environment implemented successfully

www.vidyarthiplus.com

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close