Professional Documents
Culture Documents
WAP to create simple web page by using HTML basic tags, such as
1 heading elements, list element, paragraph etc.
2 WAP to create external style sheet and using the style sheet in xml file.
OUTPUT:
Aim: 2. Experiment to implement external style sheet
and using the style sheet in xml file.
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;
}
File Name: cd_ctalog.xml
<?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 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>
</CATALOG>
Output: -
Aim: 3.To create a simple servlet program to display the date
(using Tomcat server).
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
response.setContentType("text/html");
out.println("<html><title>Date Display</title>" +
Output:
Aim: 4.To write a Javascript program to define a user defined
function for sorting the values in an array.
<html>
<head>
<script type="text/javascript">
var num=0;
number=0;
var numarray=new Array();
function array_size()
{
num=prompt("Enter how many number to be sorted","000");
number=parseInt(num);
get_numbers();
}
function get_numbers()
{
if (number!=null && number!="")
{
for( i=0;i<number;i++)
{
n=prompt("Enter the number to be sorted","1");
numarray[i]=parseInt(n);
}
}
sorting()
}
function sorting()
{
document.writeln("<h1>Sorted Array<h1>");
document.writeln(numarray.sort(sortNumber));
}
function sortNumber(a,b )
{
return a - b;
}
</script>
</head>
<body>
<h1> Click the button to get the Number sorted</h1>
<input type="button" onclick="array_size()" value="Get Array Size" />
</body>
</html>
OUTPUT:
Aim: 5. write a program to create menu using HTML and CSS
<html>
<head>
<title>menu</title>
<link rel="stylesheet" type="text/css"
href="style.css" />
</head>
<body>
<ul><li>Home</li>
<li>About</li>
<li>
Portfolio
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul>
</li>
<li>Blog
<ul>
<li>Web Design</li>
<li>Web Development</li>
<li>Illustrations</li>
</ul></li>
<li>Contact</li>
<li>Facilities</li>
<li>Downloads
<ul><li>apendix c</li>
<li>apendix d</li>
<li>apendix g</li>
</ul>
</li>
</ul>
</body>
</html>
External CSS Coding.
body {
font-family: Arial, Helvetica, sans-serif, Helvetica, Arial, sans-serif;
padding: 20px 50px 150px;
font-size: 13px;
text-align: center;
background: #E3CAA1;
}
ul {
text-align: left;
display: inline;
margin: 0;
padding: 15px 4px 17px 0;
list-style: none;
}
ul li {
font: bold 12px/18px sans-serif;
display: inline-block;
margin-right: -4px;
position: relative;
padding: 15px 20px;
background: #fff;
cursor: pointer;
}
ul li:hover {
background: #555;
color: #fff;
}
ul li ul {
padding: 0;
position: absolute;
top: 48px;
left: 0;
width: 150px;
opacity: 0;
visibility: hidden;
}
ul li ul li {
background: #CCCC33;
display: block;
color: #FF0000;
text-shadow: 0 -1px 0 #000;
}
ul li ul li:hover { background: #9966CC; }
ul li:hover ul {
display: block;
opacity: 1;
visibility: visible;
OUTPUT:-
AIM: 6.Write a program to print date using JavaScript.
<!DOCTYPE html>
<html>
<body>
<h1>My First JavaScript</h1>
<p>Click the button to display the date.</p>
<p id="demo"></p>
<button type="button" onclick="myFunction()">print
date</button>
<script>
function myFunction()
{
document.getElementById("demo").innerHTML = Date();
}
</script>
</body>
</html>
OUTPUT:-
Output:
Aim: 8. Write a program to implement border style by using
CSS. …………………………………………………………………………………..
<html>
<head>
<link rel="stylesheet" type="text/css" href="external_style.css" />
<style type="text/css">
body
{
margin-left:200px;
background:#5d9ab2 url('img_tree.png') no-repeat top left;
}
.container
{
text-align:center;
}
.center_div
{
border:1px solid gray;
margin-left:auto;
margin-right:auto;
width:90%;
background-color:#d0f0f6;
text-align:left;
padding:8px;
}
</style>
</head>
<body>
<div class="container">
<div class="center_div">
<h1>Hello World!</h1>
<p>This example contains some advanced CSS methods you may not have learned
yet. But, we will explain these methods in a later chapter in the tutorial.</p>
</div>
</div>
<p style="border-style:dotted solid dashed double">This is some text in a
paragraph.</p>
<p style="border-style:dotted solid dashed">This is some text in a paragraph.</p>
<p style="border-style:dotted solid">This is some text in a paragraph.</p>
<p style="border-style:dotted">This is some text in a paragraph.</p>
<h2>This is a header 1</h2>
<hr />
<p>You can see that the style
sheet formats the text</p>
<p><a href="cd_catalog.xml" target="_blank">This is a link</a></p>
</body>
</html>
external_style.css
<style>
h2 {color:maroon; font-size:20pt}
hr {color:navy}
p {font-size:11pt; margin-left: 15px}
a:link {color:green}
a:visited {color:yellow}
a:hover {color:black}
a:active {color:blue}
</style>
Output:-
Aim: 9.Creating Dynamic Websites Using JavaScript
[CODE]
dynamic_style.css
/*
Any styles applied here will affect the BODY tag
in your page, a good place to put background-color
or background-image definitions instead of the HTML
code, to better separate layout from content!
*/
body{
background-color: #FFFFFF;
}
.dBackgroundBox{
background-color: #FFFFFF;
}
.dColorBox{
color: #000000;
}
.dSizeBox{
width: 400px;
height: 600px;
}
.dPositionBox{
position: absolute;
left: 15px;
top: 15px;
}
[/CODE]
[CODE]
dynamic_display.js
function ModifyBGColor(id, newColor)
{
var mElement = document.getElementById(id);
mElement.style.backgroundColor = newColor;
}
function ModifyTextColor(id, newColor)
{
var mElement = document.getElementById(id);
mElement.style.color = newColor;
}
function ModifyBoxSize(id, newWidth, newHeight)
{
var mElement = document.getElementById(id);
mElement.style.width = newWidth;
mElement.style.height = newheight;
}
function ModifyBoxPosition(id, newLeft, newTop)
{
var mElement = document.getElementById(id);
mElement.style.left = newLeft;
mElement.style.top = newTop;
}
[/CODE]
[CODE]
ourTestPage.html
<HTML>
<HEAD>
<TITLE>Our Display Test</TITLE>
<script src="modules_control.js" type="text/javascript">
</script>
<script type="text/javascript">
AddModule("dynamic_display.js");
</script>
</HEAD>
<BODY>
<div class="dBackgroundBox" id="bgModBox">
<p><a onclick="ModifyBGColor('bgModBox','#FF0000');">Click here to modify the
background color!</a></p>
</div>
<div class="dColorBox" id="cModBox">
<p><a onclick="ModifyTextColor('cModBox','#00FF00');">Click here to modify
the text color!</a></p>
</div>
<div class="dSizeBox" id="szModBox">
<p><a onclick="ModifyBoxSize('szModBox','900px', '100px');">Click here to
modify the box size!</a></p>
</div>
<div class="dPositionBox" id="pModBox">
<p><a onclick="ModifyBoxPosition('pModBox','100px', '100px');">Click here to
modify the box position!</a></p>
</div>
</BODY>
</HTML>
[/CODE]
AIM: 10.Write a program to Sum and multiply two numbers using
JavaScript…………………………………………………………………………………...
<html>
<head>
<script>
function myFunction() {
var y = document.getElementById("txt1").value;
var z = document.getElementById("txt2").value;
var x = +y + +z;
document.getElementById("demo").innerHTML = x;
}
function mul() {
var y = document.getElementById("txt1").value;
var z = document.getElementById("txt2").value;
var x = +y * +z;
document.getElementById("demo").innerHTML = x;
}
</script>
</head>
<body>
<p>Click the button to calculate.</p>
<br/>
<br/>Enter first number:
<input type="text" id="txt1" name="text1"
size="6px">Enter second number:
<input type="text" id="txt2" name="text2"
size="6px"><br>
<button onClick="myFunction()">SUM</button>
<button onClick="mul()">Multiply</button>
<p id="demo"></p>
</body>
</html>
OUTPUT:
AIM: 11.Write a program to make a registration form by
using table tag in HTML.
OUTPUT:-
AIM: 11.Write a program to creat XML Http Request.
variable=new XMLHttpRequest();
Old versions of Internet Explorer (IE5 and IE6) uses an ActiveX Object:
variable=new ActiveXObject("Microsoft.XMLHTTP");
<!DOCTYPE html>
<html>
<head>
<script>
function loadXMLDoc()
var xmlhttp;
if (window.XMLHttpRequest)
xmlhttp=new XMLHttpRequest();
else
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.onreadystatechange=function()
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
</script>
</head>
<body>
</body>
</html>
output: