Академический Документы
Профессиональный Документы
Культура Документы
Page 1
INTRODUCTION:
HTML is a language for describing web pages.
HTML stands for Hyper Text Markup Language
HTML is not a programming language, it is a markup language
A markup language is a set of markup tags
HTML uses markup tags to describe web pages.
HTML tags are keywords surrounded by angle brackets like <html>.
HTML tags normally come in pairs like <b> and </b>.
The first tag in a pair is the start tag, the second tag is the end tag.
Start and end tags are also called opening tags and closing tags.
HTML documents describe web pages.
HTML documents contain HTML tags and plain text.
HTML documents are also called web pages
<html>
<body>
<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><big>This text is big</big></p>
<p><i>This text is italic</i></p>
<p><em>This text is emphasized</em></p>
<p><code>This is computer output</code></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
</body>
</html>
OUTPUT
Page 2
P2 : To add an image to a document
<html>
<body>
</body>
</html>
OUTPUT
Page 3
P3 : To draw a table in a document.
<html>
<body>
<p>
Each table starts with a table tag.
Each table row starts with a tr tag.
Each table data starts with a td tag.
</p>
<h4>One column:</h4>
<table border="1">
<tr>
<td>100</td>
</tr>
</table>
OUTPUT :
Each table starts with a table tag. Each table row starts with a tr tag. Each table data starts with a
td tag.
One column:
100
Page 4
P4: To create an unordered list.
<html>
<body>
<h4>An Unordered List:</h4>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
OUTPUT
An Unordered List:
Coffee
Tea
Milk
<html>
<body>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
OUTPUT
An Ordered List:
1) Coffee
2) Tea
3) Milk
Page 5
P6 : To create frames in a html document.
<html>
<frameset cols="25%,50%,25%">
</frameset>
</html>
OUTPUT:
Page 6
P7 . To create a form in a html document.
<html>
<body>
<form action="">
Username: <input type="text" name="user" /><br />
Password: <input type="password" name="password" />
<input type="radio" name="sex" value="male" /> Male<br />
<input type="radio" name="sex" value="female" /> Female
<input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br />
<input type="checkbox" name="vehicle" value="Car" /> I have a car
<input type="submit" value="Submit" />
</form>
</body>
</html>
OUTPUT :
Username :
Password :
Male
Female
I have a bike
I have a car
Submit
Page 7
JAVASCRIPT
S no. Name Page no.
1 Write a program to show the 10
alert box.
2 Write a program to show the 11
use of for loop.
3 To compare the two dates. 12
4 Write a program of using a 13
break label.
5 Write a program to display the 14
clock on the screen.
Page 8
INTRODUCTION:
JavaScript is the most popular scripting language on the internet, and works in all major
browsers, such as Internet Explorer, Firefox, Chrome, Opera, and Safari.
What is JavaScript?
JavaScript gives HTML designers a programming tool - HTML authors are normally
not programmers, but JavaScript is a scripting language with a very simple syntax!
Almost anyone can put small "snippets" of code into their HTML pages
JavaScript can put dynamic text into an HTML page - A JavaScript statement like
this: document.write("<h1>" + name + "</h1>") can write a variable text into an HTML
page
JavaScript can react to events - A JavaScript can be set to execute when something
happens, like when a page has finished loading or when a user clicks on an HTML
element
JavaScript can read and write HTML elements - A JavaScript can read and change the
content of an HTML element
JavaScript can be used to validate data - A JavaScript can be used to validate form
data before it is submitted to a server. This saves the server from extra processing
JavaScript can be used to detect the visitor's browser - A JavaScript can be used to
detect the visitor's browser, and - depending on the browser - load another page
specifically designed for that browser
JavaScript can be used to create cookies - A JavaScript can be used to store and
retrieve information on the visitor's computer
Page 9
P1 : Write a program to show the alert box.
<html>
<head>
<script type="text/javascript">
function show_alert()
{
alert("Hello! I am an alert box!");
}
</script>
</head>
<body onload=”show_alert();”>
</body>
</html>
OUTPUT :
Page 10
P2 . Write a program to show the use of for loop.
<html>
<body>
<script type="text/javascript">
var i=0;
for (i=0;i<=5;i++)
{
document.write("The number is " + i);
document.write("<br />");
}
</script>
<p>Explanation:</p>
<p>As long as <b>i</b> is less than, or equal to 5, the loop will continue to run.</p>
</body>
</html>
OUTPUT:
The number is 0
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5
Explanation:
This for loop starts with i=0.
As long as i is less than, or equal to 5, the loop will continue to run.
i will increase by 1 each time the loop runs.
Page 11
P3: To compare the two dates.
<html>
<head></head>
<body>
<script type=”text/javascript”>
var myDate=new Date();
myDate.setFullYear(2010,0,14);
var today = new Date();
if (myDate>today)
{
alert("Today is before 14th January 2010");
}
else
{
alert("Today is after 14th January 2010");
}
</body>
</html>
OUTPUT :
Page 12
P4 : Write a program of using break label.
<html>
<body>
<script type="text/javascript">
var i=0;
for (i=0;i<=10;i++)
{
if (i==3)
{
break;
}
document.write("The number is " + i);
document.write("<br />");
}
</script>
</body>
</html>
OUTPUT :
The number is 1
The number is 2
The number is 3
Page 13
P5 . To display a clock on screen
<html>
<head>
<script type="text/javascript">
function startTime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
// add a zero in front of numbers<10
m=checkTime(m);
s=checkTime(s);
document.getElementById('txt').innerHTML=h+":"+m+":"+s;
t=setTimeout('startTime()',500);
}
function checkTime(i)
{
if (i<10)
{
i="0" + i;
}
return i;
}
</script>
</head>
<body onload="startTime()">
<div id="txt"></div>
</body>
</html>
OUTPUT:
23:34:18
Page 14
JAVA
S no. Name Page no.
1 Write a program of single 18-19
inheritance in java
2 Write a program to swap two 20
numbers
3 Write a program for input 21
numbers in an array and find
sum and average of numbers.
Page 15
INTRODUCTION :
Java
– A programming language
– A development environment
– An application environment
– A deployment environment
Bytecode
Characteristics of Java
The target of Java is to write a program once and then run this program on multiple operating
systems.
Platform independent: Java programs use the Java virtual machine as abstraction and do
not access the operating system directly. This makes Java programs highly portable. A
Java program which is standard complaint and follows certain rules can run unmodified
all several platforms, e.g. Windows or Linux.
Object-orientated programming language: Except the primitive data types, all
elements in Java are objects.
Page 16
Strongly-typed programming language: Java is strongly-typed, e.g. the types of the
used variables must be pre-defined and conversion to other objects is relatively strict, e.g.
must be done in most cases by the programmer.
Interpreted and compiled language: Java source code is transfered into byte-code
which does not depend on the target platform. This byte-code will be interpreted by the
Java Virtual machine (JVM). The JVM contains a so called Hotspot-Compiler which
translates critical byte-code into native code.
Automatic memory management: Java manages the memory allocation and de-
allocation for creating new objects. The program does not have direct access to the
memory. The so-called garbage collector deletes automatically object to which no active
pointer exists.
The programmer writes Java source code in an text editor which supports plain text. Normally
the programmer uses an IDE (integrated development environment) for programming. An IDE
support the programmer in the task of writing code, e.g. it provides auto-formatting of the source
code, highlighting of the important keywords, etc.
At some point the programmer (or the IDE) calls the Java compiler (javac). The Java compiler
creates platform independent code which is called bytecode. This byte-code is stored in ".class"
files.
Bytecode can be executed by the Java runtime environment. The Java runtime environment
(JRE) is a program which knows how to run the bytecode on the operating system. The JRE
translates the bytecode into native code and executes it, e.g. the native code for Linux is different
then the native code for Windows.
By default, the compiler puts each class file in the same directory as its source file. You can
specify a separate destination directory with d.
Page 17
P1 : Write a program of single inheritance in java.
import java.io.*
class person
{
String name, address;
void set(String n,String a)
{
name=n;
address=a;
}
void show()
{
System.out.println("name="+name+"address="+address);
}
}
class employee extends person
{
int salary;
void setemp(int sal)
{
salary=sal;
}
void show() //overriding show of person
{
super.show();
System.out.println("salary="+salary);
}
}
class edemo
{
public static void main(String s[])
{
employee e1=new employee();
e1.set("Chinu","hno43");
e1.setemp(9000);
e1.show();
System.out.println(e1.name);
person p1=new person();
p1=e1; //upcasting
p1.set("anu "," hno23");
e1.show();
}
}
Page 18
OUTPUT:
Name: Chinu
Address: hno43
Salary:9000
Chinu
Name: Anu
Address: hno23
Page 19
P2 : Write a program to swap two numbers?
import java.io.*;
class xyz
{
int a,b;
void set(int x, int y)
{
a=x; b=y;
}
void swap ( xyz x1)
{
int temp;
temp=x1.a;
x1.a=x1.b;
x1.b=temp;
}
void show()
{
System.out.println("a="+a);
System.out.println("b="+b);
}
public static void main(String s[])throws Exception
{
xyz x2=new xyz();
int m,n;
BufferedReader br;
br=new BufferedReader(new InputStreamReader(System.in));
m=Integer.parseInt(br.readLine());
n=Integer.parseInt(br.readLine());
x2.set(m,n);
System.out.println("value of a and b before swap");
x2.show();
x2.swap(x2);
System.out.println("value of a and b after swap");
x2.show();
}
}
OUTPUT:
Value of a and b before swap:
a=10
b=20
Value of a and b after swap:
a=20
b=10
Page 20
P3 : Write a program for input in an array and find sum and average of numbers?
import java.io.*;
class mn
{
public static void main(String s[]) throws Exception
{
BufferedReader br;
br=new BufferedReader(new InputStreamReader(System.in));
int m[],avg;
m=new int[7];
System.out.println("enter anumber");
for(int i=0;i<m.length;i++)
{
m[i]=Integer.parseInt(br.readLine());
}
int sum;
sum=0;
for(int i=1;i<m.length;i++)
{
sum=sum+m[i];
}
System.out.println("sum="+sum);
avg=sum/m.length;
System.out.println(“Average=” +avg);
}
}
OUTPUT :
Enter number : 1
2
3
4
5
6
7
Sum :28
Average:4
Page 21
P4 : Write a program of exception handling in java?
class multicatch
{
public static void main(String s[])
{
try
{
int a=s.length;
int b=42/a;
System.out.println("a="+a);
try
{
if(a==1)
{
a=a/(a-a);
}
if(a==2)
{
int c[]={1};
c[42]=99;
}
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("array indes oob:"+e);
}
}
catch(ArithmeticException e)
{
System.out.println("divide by zero:"+e);
}
}
}
OUTPUT
Page 22
PHP
no. Name Page no.
1 Write a program to show the 25
use of associative arrays.
2 Write a code for php form and 26
user input.
3 Write a program to show a 27
feedback form on ur website.
4 Write a program to show the 28
use of session variables.
Page 23
INTRODUCTION :
What is PHP?
When you create a PHP application, you create PHP script files which are plain text files
comprising a combination of standard HTML code and script commands. While web servers
normally send HTML files directly to the client’s web browser in response to HTTP (HyperText
Transfer Protocol) requests, the web server first processes the content of PHP scripts before
sending output to clients. Within a PHP script, standard HTML code is sent directly to the
browser, while script commands are executed locally on the web server. The script output can
then be sent to the browser as standard HTML.
Before learning PHP we must have a basic understanding and experience in the following:
HTML - Know the syntax and especially HTML Forms.
Basic programming knowledge - This isn't required, but if you have any traditional programming
experience it will make learning PHP a great deal easier.
Page 24
P1.Write a program to show the use of associative arrays.
<html>
<body>
<?php
$ages['Peter'] = "32";
$ages['Quagmire'] = "30";
$ages['Joe'] = "34";
OUTPUT :
Page 25
P2 : Write a code for php form and user input.
<html>
<body>
</body>
</html>
<html>
<body>
</body>
</html>
OUTPUT :
Welcome John
You are 28 years old.
Page 26
P3 : Write a program to show a feedback form on your website.
<html>
<body>
<?php
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
{
//send email
$email = $_REQUEST['email'] ;
$subject = $_REQUEST['subject'] ;
$message = $_REQUEST['message'] ;
mail("someone@example.com", "$subject",
$message, "From:" . $email);
echo "Thank you for using our mail form";
}
else
//if "email" is not filled out, display the form
{
echo "<form method='post' action='mailform.php'>
Email: <input name='email' type='text' /><br />
Subject: <input name='subject' type='text' /><br />
Message:<br />
<textarea name='message' rows='15' cols='40'>
</textarea><br />
<input type='submit' />
</form>";
}
?>
</body>
</html>
OUTPUT :
Page 27
P4 : Write a program to show the use of session variables.
<?php
session_start();
// store session data
$_SESSION['views']=1;
?>
<html>
<body>
<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?>
</body>
</html>
OUTPUT :
Pageviews=1
Page 28
XML
S no. Name Page no.
1 Write a program to show the 31
use of XML DTD.
2 Write a program to load an 32
XML file-cross browser
example.
3 Write a program to show the 33
contents of an XML file as
HTML table row.
Page 29
INTRODUCTION :
What is XML?
XML is not a replacement for HTML.XML was designed to transport and store data, with focus
on what data is.HTML was designed to display data, with focus on how data looks.
USES
XML is widely used for the following purposes
Page 30
P1 : Write a program to show the use of XML DTD.
OUTPUT :
MESSAGE
To: Tove
From: Jani
Don't forget me this weekend!
Page 31
P2 : Write a program to load an XML file – Cross browser example.
<html>
<body>
<h1>W3Schools Internal Note</h1>
<div>
<b>To:</b> <span id="to"></span><br />
<b>From:</b> <span id="from"></span><br />
<b>Message:</b> <span id="message"></span>
</div>
<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","note.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.getElementById("to").innerHTML=
xmlDoc.getElementsByTagName("to")[0].childNodes[0].nodeValue;
document.getElementById("from").innerHTML=
xmlDoc.getElementsByTagName("from")[0].childNodes[0].nodeValue;
document.getElementById("message").innerHTML=
xmlDoc.getElementsByTagName("body")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
OUTPUT :
Page 32
P3 : Write a program to show the contents of XML file as an HTML table row.
<html>
<body>
<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","cd_catalog.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
document.write("<table border='1'>");
var x=xmlDoc.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].nodeValue);
document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
document.write("</table>");
</script>
</body>
</html>
OUTPUT :
Page 33
AJAX
S no. Name Page no.
1 Write a program to show the 36
implementation of AJAX.
2 Write a code to show the 37-38
fetching of information from
database using AJAX.
Page 34
INTRODUCTION
AJAX
Asynchronous JavaScript and XML.
AJAX is a technique for creating fast and dynamic web pages.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of
data with the server behind the scenes. This means that it is possible to update parts of a
web page, without reloading the whole page.
Classic web pages, (which do not use AJAX) must reload the entire page if the content
should change.
Examples of applications using AJAX: Google Maps, Gmail, Youtube, and Facebook
tabs.
Page 35
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","ajax_info.txt",true);
xmlhttp.send();
}
</script>
</head>
<body>
</body>
</html>
OUTPUT :
Change Content
Page 36
P2 :Write a code to show the fetching of information from the database with AJAX.
<html>
<head>
<script type="text/javascript">
function showCustomer(str)
{
var xmlhttp;
if (str=="")
{
document.getElementById("txtHint").innerHTML="";
return;
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","getcustomer.asp?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form action="">
<select name="customers" onchange="showCustomer(this.value)">
<option value="">Select a customer:</option>
<option value="ALFKI">Alfreds Futterkiste</option>
<option value="NORTS ">North/South</option>
<option value="WOLZA">Wolski Zajazd</option>
</select>
</form>
<br />
<div id="txtHint">Customer info will be listed here...</div>
</body>
</html>
Page 37
OUTPUT:
Select a customer:
Page 38
Index
S no. Name Page no.
1 HTML 1
2 Javascript 8
3 Java 15
4 PHP 23
5 XML 29
6 Ajax 34
Page 39
WEB TECHNOLOGY
PRACTICAL FILE
Page 40