You are on page 1of 34

Sl.

No

Experiment(s) Name

Create a web page with the following using HTML i) To embed an image map in a web page ii) To fix the hot spots ii) Show all the related information when the hot spots are clicked.

2 3 4

Create a web page with all types of Cascading style sheets. Client Side Scripts for Validating Web Form Controls using DHTML Write programs in Java to create applets incorporating the following features: Create a color palette with matrix of buttons Set background and foreground of the control text area by selecting a color from color palette. In order to select Foreground or background use check box control as radio buttons To set background images

Write programs in Java using Servlets: To invoke servlets from HTML forms To invoke servlets from Applets

Write programs in Java to create three-tier applications using JSP and Databases for conducting on-line examination. for displaying student mark list. Assume that student information is available in a database which has been stored in a database server. Programs using XML Schema XSLT/XSL Program using DOM / SAX Programs using AJAX Consider a case where we have two web Services- an airline service and a travel agent and the travel agent is searching for an airline. Implement this scenario using Web Services and Data base

7 8 9 10

EXPT NO: 01 AIM:

CREATING AND USING IMAGE MAPS

To create a web page which includes a map and display the related information when a hot spot is clicked in the map ALGOTITHM: Step 1: Create a html file with map tag Step 2: Set the source attribute of the img tag to the location of the image and also set the usemap attribute Step 3: Specify an area with name, shape and href set to the appropriate values Step 4: Repeat step 3 as many hot spots you want to put in the map Step 5: Create html files for each and every hot spots the user will select PROGRAM: ImageMap.html <HTML> <HEAD> <TITLE>Image Map</TITLE> </HEAD> <BODY><img src="india_map.jpg" usemap="#metroid" ismap="ismap" > <map name="metroid" id="metroid"> <area href='TamilNadu.html' shape='circle' coords='175,495,30' title='TamilNadu'/> <area href = "Karnataka.html" shape = "rect" coords = "100,400,150,450" title = "Karnataka" /> <area href = "AndhraPradesh.html" shape = "poly" coords = "150, 415, 175,348,265,360,190,420,190,440" title = "Andhra Pradesh" /> <area href = "Kerala.html" shape = "poly" coords = "108,455,150,515,115,490,148,495,110,448,155,501" title = "Kerala" /> </map> </BODY> </HTML> TamilNadu.html <HTML> <HEAD> <TITLE>About Tamil Nadu</TITLE> </HEAD> <BODY> <CENTER><H1>Tamil Nadu</H1></CENTER> <HR> <UL> <LI>Area : 1,30,058 Sq. Kms.</LI> <LI>Capital : Chennai</LI> <LI>Language : Tamil</LI> <LI>Population : 6,21,10,839</LI> </UL><hr>

<a href='ImageMap.html'>India Map</a> </BODY> </HTML> Karnataka.html <HTML> <HEAD> <TITLE>About Karnataka</TITLE> </HEAD> <BODY> <CENTER><H1>Karnataka</H1></CENTER> <HR> <UL> <LI>Area : 1,91,791 Sq. Kms</LI> <LI>Capital : Bangalore</LI> <LI>Language : Kannada</LI> <LI>Population : 5,27,33,958</LI> </UL> <hr> <a href='ImageMap.html'>India Map</a> </BODY> </HTML> AndhraPradesh.html <HTML> <HEAD> <TITLE>About Andhra Pradesh</TITLE> </HEAD> <BODY> <CENTER><H1>Andhra Pradesh</H1></CENTER> <HR> <UL> <LI>Area : 2,75,068 Sq. Kms</LI> <LI>Capital : Hyderabad</LI> <LI>Language : Telugu</LI> <LI>Population : 7,57,27,541</LI> </UL><hr> <a href='ImageMap.html'>India Map</a> </BODY> </HTML> Kerala.html <HTML> <HEAD> <TITLE>About Kerala</TITLE> </HEAD> <BODY> <CENTER><H1>Kerala</H1></CENTER> <HR> <UL> <LI>Area : 38,863 Sq. Kms.</LI> <LI>Capital : Thiruvananthapuram</LI>

<LI>Language : Malayalam</LI> <LI>Population : 3,18,38,619</LI> </UL><hr> <a href='ImageMap.html'>India Map</a> </BODY> </HTML> OUTPUT:

RESULT: Thus the program is executed successfully and verified.

EXPT NO: 2 AIM:

STYLESHEETS

To create a web page that displays college information using various style sheets ALGORITHM: Step 1: Create a web page with frame sets consisting two frames Step 2: In the first frame include the links Step 3: In the second frame set display the web page of the link Step 4: create a external style sheets Step 5: create a inline and internal style sheets and make it link to the external style sheets PROGRAM: XYZ.CSS: h3{font-family:arial;font-size:20;color:cyan} table{border-color:green} td{font-size:20pt;color:magenta} HTML CODE: <html> <head><h1><center>ALL STYLE SHEETS</center></h1> <title>USE of INTERNAL and EXTERNAL STYLESHEETS </title> <link rel="stylesheet" href="xyz.css" type="text/css"> <style type="text/css"> .vid{font-family:verdana;font-style:italic;color:red;text-align:center} .ani{font-family:tahoma;font-style:italic;font-size:20;text-align:center;} font{font-family:georgia;color:blue;font-size:20} ul{list-style-type: circle} </style> </head> <body> <ol style="list-style-type:lower-alpha"> <b>PTR GROUP OF COLLEGES</b><br><br><br> <li>PTR Engineering College <li>DHANAPANDIAN Polytechnic <li>Dhanapandian International School <li>Dhanapandian College of Arts and Science </ol> <p style="font-size:20pt;color:purple">PTR GROUP OF COLLEGES</p> <p class="ani">PTR Group of colleges is owned by Pandian.<br>It is approved by AICTE(All India Council for Technical Education). It is affliated to Anna University.<br></p> <h2 class="vid">PTR Engineering College</h2> <br> <font>It is an ISO certified Institution</font><br> <br> <font> <h2>List of Courses offered</h2> <ul> <li>Computer Science and Engineering</li> <li>Ece</li> <li>mech</li> <li>eee</li> </ul> </font>

<h3>Results of cse students</h3> <table width="100%" cellspacing="2" cellpadding="2" border="5"> <tr> <th>S.NAME</th> <th>MARKS</th> <th>RESULT</th> </tr> <tr> <td align="center">Dinesh</td> <td align="center">100</td> <td align="center">pass</td> </tr> <tr> <td align="center">Bala</td> <td align="center">99</td> <td align="center">pass</td> </tr> <tr> <td align="center">Gopi</td> <td align="center">98</td> <td align="center">pass</td> </tr> </table> </body> </html> OUTPUT:

RESULT: Thus the program is executed successfully and verified.

EXP NO:3 AIM:

FORM VALIDATION

To create a web page using form validation. ALGORITHM: Step1: Create a web page using forms Step2:Implement necessary fields like name,address,date of birth etc Step3:Create a validate function to perform validation in the form field Step4:Save the web page as form.html PROGRAM: <html> <head> <title>A More Complex Form with JavaScript Validation</title> <script type="text/javascript"> <!-function validate_form ( ) { valid = true; if ( document.contact_form.contact_name.value == "" ) { alert ( "Please fill in the 'Your Name' box." ); valid = false; } if ( ( document.contact_form.gender[0].checked == false ) && ( document.contact_form.gender[1].checked == false ) ) { alert ( "Please choose your Gender: Male or Female" ); valid = false; } if ( document.contact_form.age.selectedIndex == 0 ) { alert ( "Please select your Age." ); valid = false; } if ( document.contact_form.terms.checked == false ) { alert ( "Please check the Terms & Conditions box." ); valid = false; } return valid; } //--> </script> </head> <body bgcolor="#FFFFFF"> <form name="contact_form" method="post" action="/cgibin/articles/development/javascript/form-validation-with-javascript/contact_complex.cgi" onSubmit="return validate_form ( );"> <h1>Please Enter Your Details Below</h1>

<p>Your Name: <input type="text" name="contact_name"></p> <p>Your Gender: <input type="radio" name="gender" value="Male"> Male <input type="radio" name="gender" value="Female"> Female</p> <p>Your Age: <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> <p>Do you agree to the Terms and Conditions? <input type="checkbox" name="terms" value="Yes"> Yes <p><input type="submit" name="send" value="Send Details"></p> </form> </body> </html> Output:

RESULT: Thus the program is executed successfully and verified

10

EXP NO: 04 AIM:

COLOR PALETTE

To write a java program to create applets with the following feature: Create a color palette with matrix of buttons. a. Set background and foreground of the control text area by selecting a color from color palette. b. In order to select foreground or background use checkbox controls as radio buttons. c. To set background images. ALGORITHM: Step 1: Import all necessary packages and classes Step 2: Define a class that extends applet and implements action listener and item listener Step 3: Declare an array of buttons to set colors, two checkboxes for foreground and background colors Step 4: Declare a text area to hold the text, a checkbox group for checkboxes Step 5: Add the array of buttons in the init function. Step 6: In the actionPerformed() method, do the following: i) Get the action command in the string, color ii) If foreground is checked then set the foreground color to the selected color iii) If background is checked then set the background color to the selected color PROGRAM: import java.awt.*; import java.awt.event.*; import java.applet.*; /*<applet code="exp" width=400 height=400> </applet>*/ public class exp extends Applet implements ItemListener { int currcolor=5; int flag=1; String text="Click any of the buttons"; Button buttons[]=new Button[5]; String colours[]={"Red","Blue","Green","Yellow","Magenta"}; Image img; CheckboxGroup cbg=new CheckboxGroup(); Checkbox box1=new Checkbox("Background Color",cbg,true); Checkbox box2=new Checkbox("Text Color",cbg,false); Checkbox box3=new Checkbox("Loading Image",cbg,false); public void init() { for(int i=0;i<5;i++) { buttons[i]=new Button(" "); add(buttons[i]);

11

} buttons[0].setBackground(Color.red); buttons[1].setBackground(Color.blue); buttons[2].setBackground(Color.green); buttons[3].setBackground(Color.yellow); buttons[4].setBackground(Color.magenta); add(box1); add(box2); add(box3); box1.addItemListener(this); box2.addItemListener(this); box3.addItemListener(this); } public void itemStateChanged(ItemEvent ev) { if(box1.getState()==true) flag=1; else if(box2.getState()==true) { text="Default color is black"; flag=2; } else if(box3.getState()==true) { img=getImage(getDocumentBase(),"Water lilies.jpg"); flag=3; } repaint(); } public void paint(Graphics g) { if(flag==2) { g.drawString(text,30,100); switch(currcolor) { case 0: g.setColor(Color.red); break; case 1: g.setColor(Color.blue); break; case 2: g.setColor(Color.green); break; case 3: g.setColor(Color.yellow); break; case 4: g.setColor(Color.magenta); break; case 5: g.setColor(Color.black); break;

12

} g.drawString(text,30,100); } else if(flag==1) { g.drawString(text,30,100); switch(currcolor) { case 0: setBackground(Color.red); break; case 1: setBackground(Color.blue); break; case 2: setBackground(Color.green); break; case 3: setBackground(Color.yellow); break; case 4: setBackground(Color.magenta); break; case 5: setBackground(Color.white); break; } } else if(flag==3) { g.drawImage(img,20,90,this); } } public boolean action(Event e,Object o) { for(int i=0;i<5;i++) { if(e.target==buttons[i]) { currcolor=i; text="You have chosen "+colours[i]; repaint(); return true; } } return false; } }

13

OUTPUT: C:\jdk1.6.0_05\bin>javac exp.java C:\jdk1.6.0_05\bin>appletviewer exp.java

RESULT: Thus the program is executed successfully and verified.

14

EXPT NO: 05 AIM:

INVOKING SERVLETS FROM HTML

To write a program to demonstrate invoking a servlet from a html. ALGORITHM: Client: Step1: In index.jsp on the client side declare the contents that you like to transfer to the server using html form and input type tags. Step2: create a submit button and close all the included tags. Server: Step1: In the server side using the parameter request gets the stings declared in the client side (requst.getparameter) Step2: Include necessary html coding that helps to display the content Step 3: Open Web Browser and type Step 4: http://localhost:8080 Step 5: Select Tomcat Manager Step 6: Deploy the war file and Run Finally terminate the Invoking Servlets from HTML Forms PROGRAM: Servlet Code: import java.io.*; import java.util.*; import javax.servlet.*; public class PostParam extends GenericServlet { public void service(ServletRequest request,ServletResponse response) throws ServletException,IOException { PrintWriter pw = response.getWriter(); Enumeration e = request.getParameterNames(); while(e.hasMoreElements()) { String pname = (String)e.nextElement(); pw.print(pname + " = "); String pvalue = request.getParameter(pname); pw.println(pvalue); } pw.close(); } }

HTML CODE: <HTML> <head> <TITLE>INVOKING SERVLET FROM HTML</TITLE> </head> <BODY>

15

<CENTER> <FORM name = "PostParam" method = "Post" action="http://localhost:8080/servletsexamples/servlet/PostParam"> <TABLE> <tr> <td><B>Employee </B> </td> <td><input type = "textbox" name="ename" size="25" value=""></td> </tr> <tr> <td><B>Phone </B> </td> <td><input type = "textbox" name="phoneno" size="25" value=""></td> </tr> </TABLE> <INPUT type = "submit" value="Submit"> </FORM> </CENTER> </body> </html> OUTPUT:

RESULT: Thus the program is executed successfully and verified

16

EXP NO: 5B. Aim:

Invoking servlets with applets

To invoke servlets from Applet Algorithm: Start the Invoking Servlets from Applet Create the html file Create an objects in servlets. Finally save and run the program PROGRAM: <html><head><title> feedback form </title></head> <body><h1> feedback form </h1> <hr> <br> <form name="parameterpost" action="/servlets-examples/printformparams" method="post" > <table bgcolor="blanchedalmond" align="center" border="0"> <tr> <td align="center"><b>name:</b></td> <td align="center"> <input type="text" size="25" name="person"></td> </tr> <tr> <td align="center"><b>email:</b></td> <td align="center"> <input type="text" size="25" maxlength="40" name="emailaddress" ></td> </tr> <tr> <td align="center"><b>how did you find this site?</b></td> <td align="center"> <select name="from" size="1"> <option value = "website" selected>another website</option> <option value = "search engine">a search engine</option> <option value = "friend">a friend told you</option> <option value = "email">from an email</option> <option value = "unlisted">another way not listed here</option> </select> </td> </tr> <tr> <td align="center"><b>how would you rate my website:</b></td> <td align="center"> <input type="radio" name = "rating" value = "excellent"> excellent <input type="radio" name = "rating" value = "good"> good <input type="radio" name = "rating" value = "average" checked> average <input type="radio" name = "rating" value = "poor"> poor <input type="radio" name = "rating" value = "overhaul"> needs an overhaul </td> </tr> <tr>

17

<td align="center"><b>comments or suggestions:</b></td> <td align="center"> <textarea rows="6" cols="40" wrap="physical" name="suggestions"> enter any comments or suggestions you have here.</textarea> </td> </tr> <tr> <td align="center"><b>do you think this form looks nice?</b></td> <td align="center"> <input type="checkbox" name="formrating" value="yes"> </td> </tr> <tr> <td align="left"> <input type="submit" value="send comments" align="middle"> &nbsp; &nbsp; <input type="reset" value="clear form" align="middle"> </td> </tr> </form> </body> </html> <!-- web.xml --> <servlet> <servlet-name>PrintFormParams</servlet-name> <servlet-class>PrintFormParams</servlet-class> </servlet> <servlet-mapping> <servlet-name>PrintFormParams</servlet-name> <url-pattern>/PrintFormParams</url-pattern> </servlet-mapping> import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeration; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class PrintFormParams extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintParams(request, response); } public void doPost(HttpServletRequest request, HttpServletResponse response)throws Ser vletException, IOException { PrintParams(request, response); } public void PrintParams(HttpServletRequest request, HttpServletResponse response) throws IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); String htmlHeader = "<HTML><HEAD><TITLE> Printed Form Parameters </TITLE>< /HEAD><BODY>"; String htmlFooter = "</BODY></HTML>";

18

out.println(htmlHeader); out.println("<TABLE ALIGN=CENTER BORDER=1>"); out.println("<tr><th> Input Name </th><th> Value </th>"); Enumeration enum = request.getParameterNames(); while (enum.hasMoreElements()) { String inputName = (String) enum.nextElement(); String value = request.getParameter(inputName); if (value.length() != 0) { out.println("<tr><td align=center>" + inputName + "</td>"); out.println("<td align=center>" + value + "</td></tr>"); } else { out.println("<tr><td align=center>" + inputName + "</td>"); out.println("<td align=center><i>Null</i></td></tr>"); } } out.println("</TABLE><BR>"); out.println(htmlFooter); } OUTPUT:

19

EXPT NO: 06 (A) ONLINE EXAMINATION USING SERVLETS AIM: To write java servlet programs to conduct online examination and to display student mark list available in a database ALGORITHM: Client: Step1: In index.html on the client side declare the contents that you like to transfer to the server using html form and input type tags. Step2: create a submit button and close all the included tags. Servlet: Step 1: Import all necessary packages Step 2: Define a class that extends servlet Step 3: In the doPost() method, do the following: i) Set the content type of the response to "text/html" ii) Create a writer to the response iii) Get a paratmeter from the request iv) If its value is equal to right answer then add 5 to mark variable v) Similarly repeat step for all parameters vii) Display the result in an html format using the writer STUDENT MARK LIST DATABASE Step 1: Import necessary to java packages and javax packages and classes Step 2: Create a class that extends HttpServlet and implements ServletException and IOException Step 3: In the doGet() method, do the following: i) Create a PrintWriter object ii) Open a connection with the data source name iii) Write a sql query and execute to get the resultset iv) Display the resultset information in html form PROGRAM: SERVLET CODE: import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class StudentServlet3 extends HttpServlet { String message,Seat_no,Name,ans1,ans2,ans3,ans4,ans5; int Total=0; Connection connect; Statement stmt=null; ResultSet rs=null; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { try { String url="jdbc:odbc:NEO"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

20

connect=DriverManager.getConnection(url," "," "); message="Thank you for participating in online Exam"; } catch(ClassNotFoundException cnfex){ cnfex.printStackTrace(); } catch(SQLException sqlex){ sqlex.printStackTrace(); } catch(Exception excp){ excp.printStackTrace(); } Seat_no=request.getParameter("Seat_no"); Name=request.getParameter("Name"); ans1=request.getParameter("group1"); ans2=request.getParameter("group2"); ans3=request.getParameter("group3"); ans4=request.getParameter("group4"); ans5=request.getParameter("group5"); if(ans1.equals("True")) Total+=2; if(ans2.equals("False")) Total+=2; if(ans3.equals("True")) Total+=2; if(ans4.equals("False")) Total+=2; if(ans5.equals("False")) Total+=2; try { Statement stmt=connect.createStatement(); String query="INSERT INTO student("+"Seat_no,Name,Total"+") VALUES ('"+Seat_no+"','"+Name+"','"+Total+"')"; int result=stmt.executeUpdate(query); stmt.close(); }catch(SQLException ex){ } response.setContentType("text/html"); PrintWriter out=response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("</head>"); out.println("<body bgcolor=cyan>"); out.println("<center>"); out.println("<h1>"+message+"</h1>\n"); out.println("<h3>Yours results stored in our database</h3>"); out.print("<br><br>"); out.println("<b>"+"Participants and their Marks"+"</b>"); out.println("<table border=5>"); try { Statement stmt=connect.createStatement(); String query="SELECT * FROM student";

21

rs=stmt.executeQuery(query); out.println("<th>"+"Seat_no"+"</th>"); out.println("<th>"+"Name"+"</th>"); out.println("<th>"+"Marks"+"</th>"); while(rs.next()) { out.println("<tr>"); out.print("<td>"+rs.getInt(1)+"</td>"); out.print("<td>"+rs.getString(2)+"</td>"); out.print("<td>"+rs.getString(3)+"</td>"); out.println("</tr>"); } out.println("</table>"); } catch(SQLException ex){ } finally { try { if(rs!=null) rs.close(); if(stmt!=null) stmt.close(); if(connect!=null) connect.close(); } catch(SQLException e){ } } out.println("</center>"); out.println("</body></html>"); Total=0; }} HTML CODE: <html> <head><title>Database Test</title></head> <body> <center> <h1>Online Examination</h1> </center> <form action="StudentServlet3.view" method="POST"> <div align="left"><br></div> <b>Seat Number:</b> <input type="text" name="Seat_no"> <div align="Right"> <b>Name:</b> <input type="text" name="Name" size="50"><br> </div> <br><br> <b>1. Every host implements transport layer.</b><br/> <input type="radio" name="group1" value="True">True <input type="radio" name="group1" value="False">False<br> <b>2. It is a network layer's responsibility to forward packets reliably from source to destination</b><br/>

22

<input type="radio" name="group2" value="True">True <input type="radio" name="group2" value="False">False<br> <b>3. Packet switching is more useful in bursty traffic</b><br/> <input type="radio" name="group3" value="True">True <input type="radio" name="group3" value="False">False<br> <b>4. A phone network uses packet switching</b><br/> <input type="radio" name="group4" value="True">True <input type="radio" name="group4" value="False">False<br> <b>5. HTML is a Protocol for describing web contents</b><br/> <input type="radio" name="group5" value="True">True <input type="radio" name="group5" value="False">False<br> <br><br><br> <center> <input type="submit" value="Submit"><br><br> </center> </form> </body> </html> OUTPUT:

RESULT: Thus the program is executed successfully and verified.

23

EXPT NO: 6(B) AIM:

STUDENT MARKLIST USING SERVLET

To create a three tier application for displaying the student marklist ALGORITHM: Client: Step1: In index.html on the client side declare the contents that you like to transfer to the server using html form and input type tags. Step2: create a submit button and close all the included tags. Servlet: Step 1: Import all necessary packages Step 2: Define a class that extends servlet Step 3: In the doPost() method, do the following: i) Set the content type of the response to "text/html" ii) connect with the database which has the student marklist iii) query the data to the database Step 4: Display the student marklist PROGRAM: SERVLET CODE: import java.io.*; import java.sql.*; import javax.servlet.*; import javax.servlet.http.*; public class serv extends HttpServlet { String message,Reg_no; Connection connect; Statement stmt=null; ResultSet rs=null; public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException { try { String url="jdbc:odbc:NEO"; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connect=DriverManager.getConnection(url," "," "); message="Mark List"; } catch(ClassNotFoundException cnfex){ cnfex.printStackTrace(); } catch(SQLException sqlex){ sqlex.printStackTrace(); } catch(Exception excp){ excp.printStackTrace(); } Reg_no=request.getParameter("regno"); response.setContentType("text/html");

24

PrintWriter out=response.getWriter(); out.println("<html>"); out.println("<head>"); out.println("</head>"); out.println("<body bgcolor=cyan>"); out.println("<center>"); out.println("<h1>"+message+"</h1>\n"); try { Statement stmt=connect.createStatement(); String query=new String("SELECT * FROM MarkList WHERE regno= "+Reg_no); rs=stmt.executeQuery(query); boolean b=rs.next(); out.println("Regsitration No:"+rs.getInt(1)); out.println("<br>"+"Name:"+rs.getString(2)); out.println("<table border=5>"); out.println("<th>"+"cs01"+"</th>"); out.println("<th>"+"cs02 "+"</th>"); out.println("<th>"+"cs03"+"</th>"); out.println("<th>"+"status"+"</th>"); while(b) { out.println("<tr>"); out.print("<td>"+rs.getString(3)+"</td>"); out.print("<td>"+rs.getString(4)+"</td>"); out.print("<td>"+rs.getString(5)+"</td>"); out.print("<td>"+rs.getString(6)+"</td>"); out.println("</tr>"); b=rs.next(); } out.println("</table>"); } catch(SQLException ex){ out.println("error in connection"); } finally { try { if(rs!=null) rs.close(); if(stmt!=null) stmt.close(); if(connect!=null) connect.close(); } catch(SQLException e){ } } out.println("</center>"); out.println("</body></html>"); } }

25

HTML CODE: <html> <head><title> mark sheet</title></head> <body> <center> <h1>Student Mark Sheet</h1> </center> <form action="serv" method="POST"> registration number:<input type="text" name="regno"> <input type="submit" value="Submit"><br><br> </form> </body> </html> OUTPUT:

RESULT: Thus the program is executed successfully and verified.

26

EXP NO:7 AIM:

Programs XML schema

To develop a webpage containing XMl Schema ALORITHM: Step1: Step2: PROGRAM: XML document called "shiporder.xml": <?xml version="1.0" encoding="ISO-8859-1"?> <shiporder orderid="889923" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="shiporder.xsd"> <orderperson>John Smith</orderperson> <shipto> <name>Ola Nordmann</name> <address>Langgt 23</address> <city>4000 Stavanger</city> <country>Norway</country> </shipto> <item> <title>Empire Burlesque</title> <note>Special Edition</note> <quantity>1</quantity> <price>10.90</price> </item> <item> <title>Hide your heart</title> <quantity>1</quantity> <price>9.90</price> </item> </shiporder> schema file called "shiporder.xsd": <?xml version="1.0" encoding="ISO-8859-1" ?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="shiporder"> <xs:complexType> <xs:sequence> <xs:element name="orderperson" type="xs:string"/> <xs:element name="shipto"> <xs:complexType> <xs:sequence> <xs:element name="name" type="xs:string"/> <xs:element name="address" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="country" type="xs:string"/>

27

</xs:sequence> </xs:complexType> </xs:element> <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="note" type="xs:string" minOccurs="0"/> <xs:element name="quantity" type="xs:positiveInteger"/> <xs:element name="price" type="xs:decimal"/> </xs:sequence> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="orderid" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:schema>

OUTPUT:

RESULT: Thus the program is executed successfully and verified.

28

EXP NO:8
AIM:

Program using DOM

To create a web page using DOM. ALGORITHM: Step1:

PROGRAM: import java.io.*; import javax.xml.parsers.*; import org.w3c.dom.*; import org.xml.sax.*; public class Parsing_DOMDemo { public static void main(String args[]) { try { System.out.print("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

29

{ System.out.print("file not found"); } } catch(IOException ex) { ex.printStackTrace(); } } }

Output:

RESULT: Thus the program is executed successfully and verified.

30

EXP NO: 8B
AIM:

Program using SAX

To create a web page using SAX ALGORITHM: Step1:

PROGRAM: import java.io.*; import org.xml.sax.*; import org.xml.sax.helpers*; public class Parsing_SAXDemo { public static void main(String args[])throwsIOException { try { System.out.print("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 { XMLReader reader=XMLReaderFactory.createXMLReader(); reader.parse(file_name); System.out.println(file_name +"is well-formed"); } catch(Exception e) { System.out.println(file_name +"isn't well-formed"); System.exit(1); } } else {

31

System.out.print("file not present:"+file_name); } } catch(IOException ex) { ex.printStackTrace(); } } } OUTPUT:

RESULT: Thus the program is executed successfully and verified.

32

33

34

You might also like