Beruflich Dokumente
Kultur Dokumente
Ex.No : 1
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
iii) Show all the related information when the hot spots
are clicked. AIM:
To create a web page which includes a map and display the related
information when a hot spot is clicked in the map.
ALGORITHM:
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 image mapping has been performed using HTML.
Ex.No:2
CREATE A WEB PAGE WITH ALL TYPES OF CASCADING STYLE SHEETS.
AIM:
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 an 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{fontsize:20pt;color:magenta}
College.html
<html>
<head><h1><center>ALL
STYLE SHEETS</center></h1>
.ani{font-family:tahoma;fontstyle:italic;fontsize: 20;text-align:center;}
font{font-family:georgia;color:blue;fontsize:20} ul{list-style-type:circle}
</style>
</head>
<body>
<ol style="list-style-type:loweralpha"> <b>Jayaram GROUP OF
COLLEGES</b><br><br><br>
<li>Jayaram College of Engineering and
Technology</li> <li> Jayaram Polytechnic College</li>
<li>OEC</li>
<li>SACET</li>
</ol>
<p style="font-size:20pt;color:purple">Jayaram COLLEGES</p>
<p class="ani">Jayaram colleges is owned by
Er. M. Subramaniam.<br>It is approved by AICTE(All
India Council for Technical Education).It is
<h2>List of Courses
offered</h2> <ul>
<li>Computer Science and
Engineering</li> <li>Ece</li>
<li>mech</li>
<li>EIE</li>
<li>IT</li>
<li>ME-CSE</li>
<li>ME_AE</li>
<li>ME_COS</li>
<li>MCA</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">Ram</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">Ramu</td>
<td align="center">98</td> <td
align="center">pass</td> </tr>
</table>
</body>
</html>
<body>
<ol style="list-style-type:lower-alpha">
<b>Jayaram COLLEGES</b><br><br><br>
<li>OEC</li>
<li>SACET</li>
</ol>
<p style="font-size:20pt;color:purple">Jayaram GROUP OF
COLLEGES</p> <p class="ani">Jayaram colleges is owned by
Er. M. Subramaniam.<br>It is approved by AICTE(All India
<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 was executed successfully.
Ex.No 3
CLIENT SIDE SCRIPTS FOR VALIDATING WEB FORM CONTROLS
USING DHTML
Aim:
To develop an html webpage to validate form using DHTM.
ALGORITHM:
The form will include one text field called "Your Name", and a submit button.
Validation script will ensure that the user enters their name before the form is
sent to the server.
Open this page to see it in action.
Try pressing the Send Details button without filling anything in the "Your Name" field.
You might like to open the source code for this form in a separate window
The page consists of a JavaScript function called validate_form() that performs
the form validation, followed by the form itself.
Program:
PROGRAM CODE: FORM VALIDATION
<html>
<head>
<title>Student Registration Form</title>
<script type="text/javascript"> Function
validate()
{
if(document.signup.fname.value=="")
{
alert("Please Enter First Name!"); return false;
}
if(document.signup.lname.value=="")
{
alert("Please Enter Last Name!"); return false;
}
if(document.signup.uname.value=="")
{
alert("Please Enter User Name!"); return false;
}
if(document.signup.pword1.value=="")
{
alert("Please Enter Password!"); return false;
}
if(document.signup.pword1.value<6)
{
alert("Please Enter min 6 characters!");return false;
}
if(document.signup.pword2.value=="")
{
alert("Please Enter Password Again!"); return false;
}
if(document.signup.pword2.value!=document.signup.pword1.value)
{
alert("Password Mismatch Reenter Password!"); return false;
}
alert("Details Entered Successfully"); display();
}
function display()
{
document.writeln('<h2>'+"Details Entered:"+'</h2>');
document.writeln('<br/><font color="#0066ff">'+"First
Name:"+'</font>'+document.signup.fname.value);
document.writeln('<br/><font color="#0066ff">'+"Last
Name:"+'</font>'+document.signup.lname.value);
document.writeln('<br/><font color="#0066ff">'+"Use
Name:"+'</font>'+document.signup.uname.value);
document.writeln('<br/><font
color="#0066ff">'+"Country:"+'</font>'+document.signup.country.value);
document.writeln('<br/><font color="#0066ff">'+"Alternate
Email"+'</font>'+document.signup.aemail.value);
}
</script>
</head>
<body align="center" bgcolor="green"> <table width="100%"
height="100%"> <td colspan="2" width="15%">
</td>
<td colspan="1" bgcolor="#ffffff" width="70%" height="100%"> <h1
align="center"><font color="#0066ff">smail</font></h1>
<h2 align="center"><font color="#0066ff">New User Signup Form</font></h2>
<form name="signup"
onsubmit="return validate()">
<font face="verdana,arial,helvetica,sanserif" color="#660000"
size="2"> <p> *First
Name:<input type="text" name="fname" size="20"> *Last
Name:<input type="text"
name="lname" size="20"></p>
<p style="border"> *User Name:<input type="text"
name="uname" size="20">@smail.com</p>
<p style="border"> *Password:<input type="password"
name="pword1" size="20"></p>
<p style="border"> *Confirm Password:<input
type="password" name="pword2" size="20"></p>
<p> Gender:<input type="radio" name="gen"
value="male">Male<input type="radio" name="gen"
value="female">Female</p>
<p> Country:<select name="country">
<option selected>Select Country</option>
OUTPUT:
Result:
Thus, client side scripts for validating web form controls using
DHTML was successfully tested and executed.
EX NO: 4
COLOR PALETTE WITH MATRIX OF BUTTONS
Aim:
To develop a program in java to create
applets. 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,
ii) If foreground is checked then set the foreground 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;
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;
}
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;
}
}
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;
}
}
OUTPUT
C:\jdk1.6.0_05\bin>javac ColorPalette.java
C:\jdk1.6.0_05\bin>appletviewer ColorPalette.java
RESULT:
Thus, the program for implementing color palette has been executed successfully.
Ex.No:5
SERVLET PROGRAM USING HTTP
Aim:
To create a program in java using servlets.
ALGORITHM:
Start the Invoking Servlets from
Applet Create the Ats.html
Use the one input type for roll no
When
submit
button
is
click
it
perform
the
action=
<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">
</body> </html>
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application
2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Welcome to Tomcat</displayname> <description> Welcome to Tomcat
</description>
<!-- JSPC servlet mappings start --> <servlet>
<servlet-name>PostParam</servlet-name>
<servlet-class>PostParam</servlet-class>
</servlet>
<servlet-mapping> <servletname>
PostParam</servlet-name> <urlpattern>/PostParam</url-pattern>
</servlet-mapping>
<!-- JSPC servlet mappings end
--> </web-app>
Output:
OBJECTIVE
To create a program in java using servlets
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 servlet side using the parameter request get the stings declared in the
client side (requst.getparameter)
Step2: Include necessary html coding that helps to display the
content PROGRAM:
Sevlet 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>
OUTPUT:
RESULT:
Thus the given program was coded and executed successfully.
EX NO: 6
ONLINE EXAM USING JSP WITH THREE TIER ARCHITECTURE
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
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
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;
}
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";
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>
OUTPUT:
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"); 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>");
}
}
HTML CODE:
<html>
<head><title> mark
sheet</title></head> <body><center>
</form></body></html>
OUTPUT:
Result:
Thus the given
program was
coded and
executed
successfully.
EXP NO: 7
CD SHOP PROGRAM USING XML SCHEMA
Aim:
Develop a XML program describing styles into it.
Program:
<?xml version="1.0" encoding="ISO-8859-1"?> <?
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 Taylor</artist>
<country> UK</country>
<company>CBS</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>Gray Moore</artist> <country>
UK</country> <company>Virgin
Records</company>
<price>10.20</price>
<year>1990</year>
</cd>
<cd>
<title>Eros</title> <artist>Eros
Ramazotta</artist> <country>
EU</country>
<company>BMG</company>
<price>9.90</price>
<year>1997</year>
</cd>
<cd>
<title>One Night Only</title>
<artist>Bee Ges</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>
<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 Women</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 Tunes</title>
<artist>Kenny Rogers</artist>
<country> UK</country>
<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>Magesh</artist>
<country>Island</country>
<company>WEA</company>
<price>8.90</price>
<year>1990</year>
</cd>
<cd>
<title>Stop</title>
<artist>San Brian</artist>
<country> UK</country>
<company>A and M</company>
<price>8.90</price>
<year>1998</year>
</cd>
<cd>
<title>Bridge Of Spies</title>
<artist>T pall</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>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>
</CATALOG>
Result:
Thus Programs using XML-Schema-XSLT/XSL was developed and successfully executed.
Ex. No. 8
ADVANCED JAVA SCRIPT PROGRAM TO GET TEXT
Aim:
To create a text box and submit button of event handling submit form() using AJAX.
ALGORITHM:
Step 1: Start
Step2: Create a text box and submit button of event handling submit form ().
Step 3: Create new Active object of XMLHTTP under exception
Step 4: if ready state is four then get the message else error message.
Step 5: stop
PROGRAM:
<html>
<head>
<script>
function submitForm()
{ var xhr;
}}
xhr.onreadystatechange
function() { if(xhr.readyState == 4)
{
if(xhr.status == 200)
document.ajax.dyn="
else
document.ajax.dyn="Er
}};
xhr.open(GET, "data.txt",
true); xhr.send(null);
}
</script>
</head>
<body>
<FORM method="POST"
<INPUT type="BUTTON"
type="text" name="dyn"
</FORM>
</body>
</html>
Output:
Result:
Thus the AJAX program was successfully tested and executed.
Exp No: 9
IMPLEMENTING AN APPLICATION WITH WEB SERVICES
Aim:
To implement an application using web services and database.
Algorithm:
Step 1: Start the Program
Step 2: Create a root process for
Reservation Step 3: Create a service with
focus on each item Step 4: Output the items
Step 5: Stop
Program:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-var input;
var secondInput;
var element;
var secondElement;
var firstCount = 0;
var economyCount = 0;
var seats = [ ,0,0,0,0,0,0,0,0,0,0]; //allocate 10-element Array
function startArray()
{ for(var i=0; i<11; i++)
{
input = window.prompt("Please type 1 for First Class and Please type 2 for
Economy.","0"); if (input == 1 || input == 2)
{
element = linearSearch(seats);
if(element==-1&&input==1)
{
document.writeln("The First Class is already
fully booked<br/>");
secondQuestion(seats);
}
else if (element ==-1 && input == 2)
{
document.writeln("The Economy Class is already
fully booked<br/>");
secondQuestion(seats);
}
else
}
boarding
Pass(input); //to
terminate the program
else
{ window.status="Byebye!";
System.exit(0);
}}}
function linear Search(the Array)
{
if (input == 1)
{
for (var n=0; n<6 ; n++) if
(the Array [n] == 0) return n;
else if (input == 2)
{
for (var n=6; n<11 ; n++)
if (the Array [n] == 0)
return n;
}
return -1;
}
function boarding Pass(the Input)
{ if (input ==1)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the First Class<br/>");
document.writeln("Your seat number is "+ element+"<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
firstCount++;
}
else if (input ==2)
{
document.writeln("----------BOARDING PASS----------<br/>");
document.writeln("You are allocated in the EconomyClass<br/>");
document.writeln("Your seat number is
"+ element +"<br/>");
document.writeln("-----------------------------------------<br/>");
seats[element]= 1;
economyCount++;
}}
functionsecondQuestion(theArray)
{
if (input == 1)
{
for (var n=6; n<11 ;n++)
{ if (theArray [n] == 0)
{
second Input = window.prompt("Do you want to move to Economy
Class? (If YES, please press 1. If NO, please press 2)","0");
if ( second Input == 1)
{
input = 2;
element=linear Search(seats);
document.writeln("You have been allocated to
Economy Class<br/>");
boardingPass(input); break;
}
else if (secondInput == 2)
{
document.writeln("Next flight leaves in 3 hours<br/>"); break;
}}}}
else if (input == 2)
{
for (var n=0; n<6 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to First Class? (If YES,
please press 1. If NO, please press 2)","0");
for (var n=0; n<6 ;n++)
{
if (theArray [n] == 0)
{
secondInput = window.prompt("Do you want to move to First Class? (If YES, please
press 1. If NO, please press 2)","0");
boarding Pass(input); break;
}
else if (secondInput == 2)
{
document.writeln("Next flight leaves in 3
hours<br/>"); break;
} }}}
//-->
</script>
</head>
<body onload =
"startArray()"></body> </html
Output:
Result:
The web service for the required application is created.