Chapter 3: WEB TECHNOLOGY
What is the Internet?
·
The
Internet is a worldwide network of computers.
·
It
allows computers to share information with each other.
·
Uses
TCP/IP protocol for communication.
How Internet
Works ?
·
Your
device sends a request (example: Google search).
·
The
request goes through the internet.
·
The
server sends back the webpage you asked for.
Important
Internet Terms
a)
WWW (World Wide Web)
A
collection of web pages connected through links.
b)
Web Browser
Software
used to view web pages.
Examples:
Chrome, Firefox, Edge.
c)
Web Server
A
computer that stores websites and sends them when users request.
d)
URL (Uniform Resource Locator)
The
address of a webpage.
Example:https://www.google.com
e)
Domain Name
Human-friendly
name of a website.
Example:
facebook.com
f)
IP Address
Numeric
address of a computer.
Example:
192.168.1.1
2. Client-Side
and Server-Side Scripting
What
is Scripting?
Writing
small programs that run inside web pages.
a) Client-Side
Scripting
Runs
inside the browser.
Examples:
JavaScript
HTML
CSS
Uses:
·
Checking
forms (email, password)
·
Creating
animations
·
Changing
colors, images, text
Note:It does NOT communicate with the
database.
b) Server-Side
Scripting
Runs
on web server (not in the user's browser).
Examples:
PHP
Python Django
ASP.NET
Uses:
·
Storing
data in database
·
Checking
login
·
Creating
user accounts
·
Generating
web pages dynamically
Note:It CAN talk to databases.
Difference
between Client-Side and Server-Side Scripting
|
Client-Side Scripting |
Server-Side
Scripting |
|
Client
side scripting is used at the front end which users can see from the browser |
Server
side scripting is used at the backend where the source code is not viewable
or hidden at the client side browser |
|
Its
main function is to provide the requested output to end user. |
Its
primary function is to manipulate and
provides access to the respective database as per the request |
|
It
runs on the user’s computer . |
It
runs on the webserver |
|
Client
side scripting does not need any server interaction |
When
a server side script is processed it communicates to the server |
|
It
usually depends on the browser and its version. |
In
this any server side technology can be used and it does not depend on
the client |
|
It
is useful in minimizing the load on the
server |
It
is useful in customizing the web pages and implementing dynamic changes in
the website. |
|
It
is not secured compared to the server side as a client side script is visible
to the users |
It
is more secure than client side scripting as scripts are usually hidden from
the client end. |
|
The
client side scripting langauges involves languages such as html css and
javascript |
Server
side language involves programming such as PHP, ASP.NET, Python, C#, JSP etc. |
1.
Write
a JavaScript program to add two numbers
<html>
<head>
<title>Sum of Two
Numbers</title>
</head>
<body>
<script>
var a =
parseInt(prompt("Enter 1st number"));
var b =
parseInt(prompt("Enter 2nd number"));
var sum = a
+ b;
document.write("The
sum is: " + sum);
</script>
</body>
</html>
Using function
<html>
<head>
<title>Sum of Two
Numbers</title>
</head>
<body>
<script>
var a =
parseInt(prompt("Enter 1st number"));
var b =
parseInt(prompt("Enter 2nd number"));
function
sum(a, b) {
var
x = a + b;
document.write("The
sum is: " + x);
}
sum(a, b);
</script>
</body>
</html>
2.Write a JavaScript program to find simple interest.
<html>
<head>
<title>Simple interest</title>
</head>
<body>
<script>
var p = parseInt(prompt("Enter Principle"));
var t = parseInt(prompt("Enter time"));
var r = parseInt(prompt("Enter rate"));
var si = (p*t*r)/100;
document.write("Simple Interest=Rs " +si);
</script>
</body>
</html>
Using Function
<html>
<head>
<title>Area of
circle</title>
</head>
<body>
<script>
var p = parseInt(prompt("Enter principle"));
var
t = parseInt(prompt("Enter time"));
var
r = parseInt(prompt("Enter rate"));
function
si(p,t,r)
{
var si = (p*t*r)/100;
document.write("Simple
interest=Rs" +si);
}
si(p,t,r);
</script>
</body>
</html>
3. Write a JavaScript program to find area of circle.
<html>
<head>
<title>area of circle</title>
</head>
<body>
<script>
var r = parseInt(prompt("Enter radius"));
var area = (22/7)*r*r;
document.write("Area of circle=" +area);
</script>
</body>
</html>
Using function
<html>
<head>
<title>Area of circle</title>
</head>
<body>
<script>
var r = parseInt(prompt("Enter radius"));
function area(r)
{
var area = (22/7)*(r*r);
document.write("Area of circle: " + area);
}
area(r);
</script>
</body>
</html>
4.Write a JavaScript program to find greatest among of two numbers.
<html>
<head>
<title>Greatest
among of two numbers</title>
</head>
<body>
<script>
var a =
parseInt(prompt("Enter 1st number"));
var b =
parseInt(prompt("Enter 2nd number"));
if(a>b)
{
alert(a+
"is greatest");
}
else
{
alert(b+
"is greatest");
}
</script>
</body>
</html>
Using Function
<html>
<head>
<title>Greatest among of two numbers</title>
</head>
<body>
<script>
var a = parseInt(prompt("Enter 1st number"));
var b = parseInt(prompt("Enter 2nd number"));
function greatest(a,b)
{
if(a>b)
{
alert(a+ "is greatest");
}
else
{
alert(b+ "is greatest");
}
}
greatest(a,b);
</script>
</body>
</html>
5.
Write
a JavaScript program to find greatest among of three numbers.
<html>
<head>
<title> Greatest among
of three numbers</title>
</head>
<body>
<script>
var a =
parseInt(prompt("Enter 1st number"));
var b =
parseInt(prompt("Enter 2nd number"));
var c =
parseInt(prompt("Enter 3rd number"));
if(a>b&&a>c)
{
alert(a+
"is greatest");
}
else
if(b>a&&b>c)
{
alert(b+
"is greatest");
}
else
{
alert(c+
"is greatest");
}
</script>
</body>
<html>
<head>
<title>
series</title>
</head>
<body>
<script>
for(i=1;i<=10;i=i+1)
{
document.write(i +"<br>");
}
</script>
</body>
</html>
9. 1,3,5,……… upto 10th term
<html>
<head>
<title> series</title>
</head>
<body>
<script>
a=1;
for(i=1;i<=10;i=i+1)
{
document.write(a
+" ");
a=a+2;
}
</script>
</body>
</html>
10.2,4,6…..upto 10th term
<html>
<head>
<title> series</title>
</head>
<body>
<script>
a=2;
for(i=1;i<=10;i=i+1)
{
document.write(a
+" ");
a=a+2;
}
</script>
</body>
</html>
]12. 2 4 7 11 16 ……….upto 10th term
<html>
<head>
<title> series</title>
</head>
<body>
<script>
a=1;
for(i=1;i<=10;i=i+1)
{
document.write(a
+" ");
a=a+i;
}
</script>
</body>
</html>
13. 5 10 15 20……………..upto 10th term
<html>
<head>
<title> series</title>
</head>
<body>
<script>
for(i=1;i<=10;i=i+1)
{
a=5;
a=a*i;
document.write(a
+" ");
}
</script>
</body>
14. 5,25 125 625………..upto 10th term
<html>
<head>
<title> series</title>
</head>
<body>
<script>
a=5;
for(i=1;i<=10;i=i+1)
{
document.write(a
+" ");
a=a*5;
}
</script>
</body>
</html>
15. Write a JavaScript Code snippet, along with HTML, that displays the multiplication table of a entered number.
<html>
<head>
<title>Multiplication Table</title>
</head>
<body>
<script>
var a = parseInt(prompt("Enter a number"));
for (var i = 1; i <= 10; i++) {
document.write(a + " × " + i + " = " + (a * i) +
"<br>");
}
</script>
</body>
</html>1
6. Write a JavaScript code to calculate the factorial of a given number.
<html>
<head>
<title>Factorial of a Number</title>
</head>
<body>
<script>
var n = parseInt(prompt("Enter a number"));
var fact = 1;
for (var i = 1; i <= n; i++) {
fact = fact * i;
}
document.write("Factorial of " + n + " is: " +
fact);
</script>
</body>
</html>
Write a program to display factors of a given number.
<html>
<head>
<title>Factor</title>
</head>
<body>
<script>
var n = parseInt(prompt("Enter a number"));
document.write("Factors: ");
for (var i = 1; i <= n; i++) {
if (n % i === 0) {
document.write(i + " ");
}
}
</script>
</body>
</html>