Internet Programming Lab1
Internet Programming Lab1
ALGORITHM:
1. Start the program.
2. Get the india map image and link it to the package.
<img src="flag.jpg">
<img align="right" src = "India Map.gif" usemap="#india">
3. Fix the hotspots in that image.
4. Map the reference of the hotspots in the image.
<area shape="circle" coords="274,745,20" href="tn.html">
5. Mention the derived link.
6. Click the link to get the desired image.
7. Stop the program.
SOURCE CODE:
Main.html
<html>
<head>
<BODY bgcolor="#gop6876cgdt5564ss">
<img src ="indiamap.jpeg" usemap="indiamap" />
<map name=indiamap>
<AREA SHAPE="rect" COORDS="190,477,251,562" HREF="tamilnadu.html"
target="tamilnadu.html" >
<AREA SHAPE="rect" COORDS="158,477,195,564" HREF="kerala.html"
target="kerala.html" >
<AREA SHAPE="rect" COORDS="217,378,238,472,350,361" HREF="andhra.html"
target="andhra.html" >
<AREA SHAPE="rect" COORDS="160,474,212,401,189,436" HREF="karnataka.html"
target="karnataka.html" >
<AREA SHAPE="rect" COORDS="137,382,219,311,129,331" HREF="maharashtra.html"
target="maharashtra.html" >
<AREA SHAPE="rect" COORDS="392,319,334,304,309,362," HREF="orissa.html"
target="orissa.html" >
<AREA SHAPE="rect" COORDS="232,244,238,306,168,283" HREF="madhayapradesh.html"
target="madhayapradesh.html" >
</map>
</head>
</html>
Tamiladu.html
<html>
<head>
<body bgcolor="#fggbhjgdhg"/>
<center><h2>it is a tamilnadu,here maximum tamilan living and capital of tamilnadu is
</h2><h1>chennai<h1></center>
</head>
</html>
Kerala.html
<html>
<head>
<body bgcolor="#7674dshddf"/>
<center>it is a kerala,here maximum malaiyalees living and capital of kerala is
<h1>Thiruvananthapuram</h1></center>
</head>
</html>
Karataka.html
<html>
<head>
<body bgcolor="#7674dshddf"/>
<center>it is a karnataka,here maximum kannadam living and capital of karnataka is
<h1>Bangalore</h1></center>
</head>
</html>
Madhyapradesh.html
<html>
<head>
<body bgcolor="blue"/>
<center>it is a madhyapradesh,here maximum maratiyam living and capital of madhyapradesh
is <h1>BHOPAL</h1></center>
</head>
</html>
Maharastra.html
<html>
<head>
<body bgcolor="blue"/>
<center>it is a maharashtra,here maximum maratiyam living and capital of maharashtra is
<h1>Mumbai</h1></center>
</head>
</html>
Orissa.html
<html>
<head>
<body bgcolor="blue"/>
<center><h2>it is a orissa,here maximum oreya living and capital of orissa is</h2>
<h1>Bhubaneswar</h1></center></head></html>
Output:
RESULT:
Thus the web page is created and the image is embedded with hot spot and the linking
ages successfully, and the output is verified.
STYLE SHEET
AIM:
To write a webpage that displays college information using various style sheet.
ALGORITHM:
1. Start the program.
2. Create a web page with framesets consisting two frames.
3. In the first frame include the links.
4. In the second frameset display the webpage of the link.
5. Create a external style sheets.
6. Create a inline and internal style and make a link to the external style sheet.
7. Stop the program.
SOURCE CODE:
<html>
<head>
<title>Cascading Style Sheets</title>
</head>
<body alink="blue" vlink="brown">
<h1><u><b><font face="Monotype corsiva" color="red">
Different types of Cascading Style Sheets</font> </b></u></h1>
<br />
<font face="Arial"size="6">
<a href ="inline.html" style="text-decoration :none;"> 1. Inline Style Sheet</a><br />
<a href ="embedded.html" style="text-decoration :none;"> 2. Embeded Style
Sheet</a><br />
<a href ="external.html" style="text-decoration :none;"> 3. External Style
Sheet</a><br />
<a href ="import.html" style="text-decoration :none;"> 4. Imported Style
Sheet</a><br /></font>
</body>
</html>
Inline.html
<html>
<head>
<title>Inline Style Sheet</title>
</head>
<body>
<ol class="decimal">
<h1 style="font-family :Monotype Corsiva ;background-color:antiquewhite ;"><li>
Inline Style Sheet</li></h1>
<h3>
<p style="text-indent :30pt;color:blue;font-family :arial;">
Inine Style is the style attached to one specific element.
The style is specified directly in the start tag as a value of the style attribute well apply
exclusively to this specific element occurrence.
</p></h3>
</ol>
</body>
</html>
Embedded.html
<html>
<head>
<title>Embeded Style Sheet</title>
<style type="text/css">
ol{list-style-type:decimal}
h1{text-align: left; background:antiquewhite;font-family:monotype corsiva;color:red}
h3{text-align: right; font-family:arial;color:blue}
</style>
</head>
<body>
<ol class="lroman"><h1>
<li>Embedded style sheet</li></h1>
<br />
Embedded style is the style attached to one specific document.
The information is specified as a content of the style element
inside the head element and wil apply to the entire documents.
</h3></ol>
</body>
</html>
External.html
<html>
<head>
<title>External Style Sheet</title>
<link rel=Stylesheet href="style1.css" type="text/css" />
</head>
<body>
<h1>1. External Style Sheet</h1><br />
<h3>
An external style sheet is a template documents/files
containing style info which can be linked with any number
of the documents. This is a very convenient way of formating
the entire site as well as restyling it by editing just one file</h3>
</body>
</html>
Import.html
<html>
<head><title>Imported Style Sheet</title>
<link rel= stylesheet href="style2.css" type="text/css">
</head>
<body>
<h1>1. Imported Style Sheet</h1>
<h3> Imported style sheet is a shet that can be imported to another sheet.
This alignes exacting one main sheet containing declarations that apply to
the whle site and partial sheets containing declarations that apply to specific
elements.</h3>
</body>
</html>
Output:
RESULT:
Thus the web page is created using all tyes of cascading style sheets successfully and the
output is also verified.
WEB FORM VALIDATION
AIM:
To write a DHTML code for creating the web page for validating the web form.
ALGORITHM:
1.The form will include one text field called "Your Name", and a submit button.
2.Validation script will ensure that the user enters their name before the form is sent to the
server.
3. Open this page to see it in action.
4. Try pressing the Send Details button without filling anything in the "Your Name" field.
5.You might like to open the source code for this form in a separate window
6. The page consists of a JavaScript function called validate_form() that performs the form
validation, followed by the form itself.
SOURCE CODE:
<html>
<head>
<title>A Simple 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.contact_name.value)
{
alert("Your details had sended");
valid=true;
}
return valid;
}
//-->
</script>
</head>
<body bgcolor=”#FFFFFF”>
<form name="contact_form" method="post"
action="css.html"
onSubmit="return validate_form();">
<h1>Please Enter Your Name</h1>
<p>Your Name: <input type="text" name="contact_name"></p>
<p><input type="submit" name="send" value="Send Details"></p>
</form>
</body>
</html>
OUTPUT:
RESULT:
Thus the program has been written for creating the web page for validating the
informations.
APPLET CREATION
AIM:
To write a java program to create the applets.
ALGORITHMS:
1. Write a HTML applet tag with code set, class name, and comment the tag.
2.Import all necessary packages and classes.
3.Define a class that extends applet and implements action listener and item listener.
4.Declare an array of buttons to set colors , two check boxes for foreground and
background colors.
5. Declare a text area to hold the text, a check box group for check boxes.
6. Declare three panels, button panel, palette panel and check pael.
7. Declare a string, color.
8.Display the result.
9.Stop the program.
SOURCE CODE:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
ALGORITHM:
1. Import the package that are necessary to create an palette color.
2. Allocate memory location for buttons and checkbox group by Using new keyword.
3. Set the background and by using the background.
4. Add the component color by using add method.
5. Call the methods for listening the action.
6. The getimage method is used to get the image and displayed Onto the screen.
7. Compile and run the program.
SOURCE CODE:
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
/*<Applet code="colorpl" height=600 width=600></applet>*/
public class colorpl extends Applet implements ItemListener
{
int currcolor=5;
int flag=1;
String text="click any of the button";
Button buttons[]=new Button[5];
String colors[]={"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]);
}
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 ie)
{
if(box1.getState()==true)
flag=1;
if(box2.getState()==true)
{
text="default color is Black";
flag=2;
}
if(box3.getState()==true)
{
img=getImage(getDocumentBase(),"jelly.bmp”);
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;
}
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;
}
g.drawString(text,30,100);
}
else if(flag==3)
{
rawImage(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" +colors[i];
repaint();
return true;
}}
return false;
}}
OUTPUT:
RESULT:
Thus the java program for color palette was executed and verified.
INVOKING SERVLET FROM HTML FORMS
AIM:
To write a java program for invoking servlet from HTML form.
ALGORITHM:
1. Start the program.
2. Create the form as ResponseDemoServlet with textfield,submit
Button and reset button.
3. The class ResponseDemoServlet implements the interface servlet.
4. Create the out object for the PrintWriter class and call the method
Getwriter as response.getwriter.
5. Display the server port, server name, protocol, character encoding, content length.
6. Create the class as enumeration with parameters as object.
7. Stop the program.
SOURCE CODE:
Client Page:
<HTML>
<HEAD>
<TITLE>Sending a request</TITLE>
</HEAD>
<BODY>
<FORM ACTION= ResponseDemoServlet METHOD="POST">
<BR><BR>
Author: <INPUT TYPE="TEXT" NAME="Author">
<INPUT TYPE="SUBMIT" NAME="Submit">
<INPUT TYPE="RESET" VALUE="Reset">
</FORM>
</BODY>
</HTML>
Server Page:
importjavax.servlet.*;
importjava.io.PrintWriter;
importjava.io.IOException;
importjava.util.Enumeration;
public class ResponseDemoServlet implements Servlet {
public void init(ServletConfigconfig) throws ServletException {
} public void destroy() { }
public void service(ServletRequest request, ServletResponse response)
throwsServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>");
out.println("ServletResponse");
out.println("</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<B>Demonstrating the ServletResponse object</B>");
out.println("<BR>");
out.println("<BR>Server Port: " + request.getServerPort());
out.println("<BR>Server Name: " + request.getServerName());
out.println("<BR>Protocol: " + request.getProtocol());
out.println("<BR>Character Encoding: " + request.getCharacterEncoding());
out.println("<BR>Content Type: " + request.getContentType());
out.println("<BR>Content Length: " + request.getContentLength());
out.println("<BR>Remote Address: " + request.getRemoteAddr());
out.println("<BR>Remote Host: " + request.getRemoteHost());
out.println("<BR>Scheme: " + request.getScheme());
Enumeration parameters = request.getParameterNames();
while (parameters.hasMoreElements()) {
String parameterName = (String) parameters.nextElement();
out.println("<br>Parameter Name: " + parameterName);
out.println("<br>Parameter Value: " +
request.getParameter(parameterName));
}
Enumeration attributes = request.getAttributeNames();
while (attributes.hasMoreElements()) {
String attribute = (String) attributes.nextElement();
out.println("<BR>Attribute name: " + attribute);
out.println("<BR>Attribute value: " + request.getAttribute(attribute));
}
out.println("</BODY>");
out.println("</HTML>");
}
public String getServletInfo() {
return null;
}
publicServletConfiggetServletConfig() {
return null;
}
}
OUTPUT:
RESULT:
Thus the program for invoking servlet from HTML form was executed and the output
was verified.
INVOKING SERVLET FROM SERVLET FORM
AIM:
To write a program for invoking servlet from HTML form.
ALGORITHM:
1. Start the program.
2. Create the class as Loginservlet.
3. Enter the username and password in the form.
4. If username and password are correct then the welcome servlet page is opened.
5. Else the message “Loginfailed” will be displayed.
6. RequestDispatcher is used to transfer messages efficiently.
7. Stop the program.
SOURCE CODE:
LOGIN Page:
importjavax.servlet.*;
importjavax.servlet.http.*;
import java.io.*;
importjava.util.*;
public class LoginServlet extends HttpServlet {
private void sendLoginForm(HttpServletResponse response,
booleanwithErrorMessage)
throwsServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Login</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
if (withErrorMessage)
out.println("Login failed. Please try again.<BR>");
out.println("<BR>");
out.println("<BR>Please enter your user name and password.");
out.println("<BR><FORM METHOD=POST>");
out.println("<BR>User Name: <INPUT TYPE=TEXT NAME=userName>");
out.println("<BR>Password: <INPUT TYPE=PASSWORD NAME=password>");
out.println("<BR><INPUT TYPE=SUBMIT VALUE=Submit>");
out.println("</FORM>");
out.println("</BODY>");
out.println("</HTML>");
}public void doGet(HttpServletRequest request, HttpServletResponse response)
throwsServletException, IOException {
sendLoginForm(response, false);}
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throwsServletException, IOException {
String userName = request.getParameter("userName");
String password = request.getParameter("password");
if (userName!=null && password!=null &&
userName.equals("jamesb") &&password.equals("007")) {
RequestDispatcherrd = request.getRequestDispatcher("WelcomeServlet");
rd.forward(request, response);
}else {
sendLoginForm(response, true);
} }}
Response Page for Login:
importjavax.servlet.*;
importjavax.servlet.http.*;
import java.io.*;
public class WelcomeServlet extends HttpServlet {
public void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Welcome</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("<P>Welcome to the Bulbul's and Boni's Web Site.</P>");
out.println("</BODY>");
out.println("</HTML>");
}
}
OUTPUT:
RESULT:
Thus the program for login page and its response was done successfully and the output
was verified.
ONLINE EXAMINATION
AIM:
To write the JSP program for online examination.
ALGORITHM:
1. Start the program.
2. With the scriplet tag, include information like document
Created on and author.
3. Set the content type using page content type=”txt\html”.
4. Include the doctype with transitional flavour.
5. Get the input as regno , name and store in the table.
6. Create the forms as exam and index.
7. Click the submit button, after completing all the
questions. If the answers are correct it will display
as correct else incorrect.
8. Stop the program.
SOURCE CODE:
Newjsp.jsp:
<%--
Document : exam
Created on : Feb 23, 2011, 7:19:15 PM
Author : A
--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Examination Panel</title>
</head>
<body bgcolor="cyan">
<%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
String reg= request.getParameter("txt_reg");
String name = request.getParameter("txt_name");
out.println("<h2>Welcome" + name + "...Your Register number is " + reg +
"!!</h2><br><br><br>");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM " + sTable + "";
String database = "jdbc:odbc:sDBQ";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"sa","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
while(rs.next())
{
out.println("<form name='exam' action='newjsp2.jsp' method='post'><b>"+i+" . " +
rs.getString(1) + "</b><br><br>");
s1 = rs.getString(2);
s2 = rs.getString(3);
s3 = rs.getString(4);
s4 = rs.getString(5);
out.println("<input type=radio name=opt"+i+" value="+s1+" CHECKED>"+ s1 +" <br><br>");
out.println("<input type=radio name=opt"+i+" value="+s2+">" + s2 +"<br><br>");
out.println("<input type=radio name=opt"+i+" value="+s3+">" + s3 +"<br><br>");
out.println("<input type=radio name=opt"+i+" value="+s4+">" + s4 +"<br><br>");
i++;
}
out.println("<input name ='submit' value='Submit' type='submit'/>");
/*int n = rsmd.getColumnCount();
out.println( "<table border=1 cellspacing=3><tr>" );
for( int i=1; i<=n; i++ ) // Achtung: erste Spalte mit 1 statt 0
out.println( "<th>" + rsmd.getColumnName( i ) + "</th>" );
while( rs.next() )
{out.println( "</tr><tr>" );
for( int i=1; i<=n; i++ ) // Achtung: erste Spalte mit 1 statt 0
o ut.println( "<td nowrap>" + rs.getString( i ) + "</td>" );
}
out.println( "</tr></table>" );*/
}finally {
try { if( null != rs ) rs.close(); } catch( Exception ex ) {}
try { if( null != st ) st.close(); } catch( Exception ex ) {}
try { if( null != cn ) cn.close(); } catch( Exception ex ) {}
}
%> </body>
</html>
Newjsp1.jsp
<%--
Document : index
Created on : Feb 9, 2011, 6:50:54 PM
Author : A
--%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Welcome to Online Examination</title>
</head>
<body bgcolor="cyan">
<form name="index" action="newjsp.jsp" method="post">
<center><h1><span><font color="red">Welcome to Online
Examination</font></span></h1>
<br>
<h2><u><span><font color="blue">Instructions to the
Candidates</font></span></u></h2>
<br><h3><ol><li>Fill the correct Registration number.</li>
<br><li>Enter your name.</li>
<br><li>Read the questions carefully.</li>
<br><li>No negative marking.</li></ol></h3>
<br>
<b>Enter your Register number</b>
<input type="text" name="txt_reg">
<b>Enter your Name</b>
<input type="text" name="txt_name"><br><br>
<input name ="submit" value="Submit" type="submit"/>
</center>
</form>
</body>
</html>
Newjsp2.jsp
<%--
Document : report
Created on : Feb 23, 2011, 9:09:37 PM
Author : A
--%>
<%@page import="com.sun.java.swing.plaf.windows.resources.windows_es"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Exam Report</title>
</head>
<body bgcolor="cyan">
<center><h1>Your Report Card</h1></center>
<%@ page language="java" %>
<%@ page import ="java.sql.*" %>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String sTable = "exam";
String sSql = "SELECT * FROM " + sTable + "";
String database = "jdbc:odbc:sDBQ";
Connection cn = null;
Statement st = null;
ResultSet rs = null;
try {
cn = DriverManager.getConnection( database ,"sa","");
st = cn.createStatement();
rs = st.executeQuery( sSql );
ResultSetMetaData rsmd = rs.getMetaData();
String s1,s2,s3,s4;
int i=1;
int correct=0,incorrect=0,total=0;
out.println("<h2><br><br><center><table border=1 cellpadding=2
cellspacing=2><tr><th>Question</th><th>Your Answer</th><th>Correct
Answer</th><th>Status</th></tr>");
while(rs.next())
{
total++;
s1 = rs.getString(1);
s2 = request.getParameter("opt"+i);
s3 = rs.getString(6);
if(s2.equals(s3))
{ s4="Correct";
correct++;
}
else
{ s4="Incorrect";
incorrect++;
}
out.println("<tr><td>"+s1+"</td><td>"+s2+"</td><td>"+s3+"</td><td>"+s4+"</td></tr>");
i++;
}
out.println("</table><br><br><table><b><tr><td>Correct
Answers</td><td>"+correct+"</td></tr>");
out.println("<tr><td>Incorrect Answers</td><td>"+incorrect+"</td></tr>");
out.println("<tr><td>Total
Questions</td><td>"+total+"</td></tr></table></b></center></h2>");
}
finally {
try { if( null != rs ) rs.close(); } catch( Exception ex ) {}
try { if( null != st ) st.close(); } catch( Exception ex ) {}
try { if( null != cn ) cn.close(); } catch( Exception ex ) {}
}
%>
</body>
</html>
OUTPUT:
RESULT:
Thus the JSP program for online examination was executed by connecting the SQLSERVER
and result was verified
XML – Schema – XSLT/XSL
AIM:
To write a XML scheme to generate CD Collection details
ALGORITHM:
Step 1: Start the program
Step 2: Use Xml Style Sheet code to define link
<?xml-stylesheet type="text/xsl" href="yourxsl.xsl"?>
Step 3: Use the catalog tag to define CD collection details.
Step 4: Use the necessary heading for appropriate XML tag.
Step 5: Provide necessary information for CD collection details
Step 6: Stop the program
SOURCE CODE:
Username.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<?xml-stylesheet type="text/xsl" href="yourxsl.xsl"?>
<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>
<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>
<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>
<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>
</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>
<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>
</cd>
</catalog>
yourxsl.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
RESULT:
Thus the XML scheme to generate CD Collection details was executed successfully
and verified.
AJAX.
AIM:
To write a java script program for a AJAX.
ALGORITHM:
1. Start the program.
2.A scripting language that is commonly hosted in a browser to add
Interactivity to HTML PAGES.
3. Defines the structure of a webpage as a set of programmable objects
that can be accessed through javascript.
4. Allows a client-side script to perform and httprequest.
5. AJAX applications use xmlhttprequest object to perform asynchronous
requests to the server as opposed to performing a full page refresh.
6. Display the result.
7. Stop the program.
PROGRAM:
<html>
<head>
<script type="text/javascript">
functionloadXMLDoc()
{
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 &&xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","new.txt",true);
xmlhttp.send();
}
</script>
<title>ajax program</title>
</head>
<body>
<div id="myDiv"><h2>Let AJAX change this text</h2></div>
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</body>
</html>
New.txt:
WELCOME!!!
OUTPUT:
RESULT:
Thus the program for AJAX was executed and the output was verified.
IMPLEMENTING AN APPLICATION USING THE WEB SERVICES
AIM:
To implement a application using the web services.
ALGORITHM:
1. Start the program
2. Create a root rocess for reservation
3.Create a service with focus on each item
4.Run the program, display the result
5.Stop the program.
SOURCE CODE:
<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- Solution11.16 -->
<!-- Airline Reservation System-->
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<title>Airline Reservation System</title>
<script type = "text/javascript">
<!--
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="Bye-bye!";
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:
Thus the program is executed and verified successfully.