FSWD Unit I
FSWD Unit I
A web server is a software program that serves web pages to web users (browsers).
A web server delivers requested web pages to users who enter the URL in a web browser. Every
computer on the internet that contains a web site must have a web server program.
The computer in which a web server program runs is also usually called a "web server". So, the term
"web server" is used to represent both the server program and the computer in which the server
program runs.
All web sites in the internet are hosted in web servers sitting in various parts of the world.
Mostly, Web server refers to the software program, that serves the clients request. But sometimes,
the computer in which the web server program is installed is also called a "web server".
When I type in an URL such as http://www.ASP.NET and click on some link, I dropped into this
page.
But what happens behind the scenes to bring you to this page and make you read this line of text.
The first you might do is, you type the http://www.asp.net/ in the address bar of your browser and
press your return key.
When you try to access a web site, you don't really need to know where the web server is located.
The web server may be located in another city or country, but all you need to do is, type the URL of
the web site you want to access in a web browser. The web browser will send this information to the
internet and find the web server. Once the web server is located, it will request the specific web page
from the web server program running in the server. The Web server program will process your
request and send the resulting web page to your browser. It is the responsibility of your browser to
format and display the web page to you.
Typically, there is only one web server required for a web site. But large web sites like Yahoo,
Google, MSN and so on will have millions of visitors every minute. One computer cannot process
such huge numbers of requests. So, they will have hundreds of servers deployed in various parts of
the world so that can provide a faster response.
Prepared by. E.Janakiraman.MCA,Mphil,. AP/MCA Page 2
MC4201 – FULL STACK WEB DEVELOPMENT UNIT - 1
A web server can host hundreds of web sites. Most of the small web sites in the internet are hosted
on shared web servers. There are several web hosting companies who offer shared web hosting. If
you buy a shared web hosting from a web hosting company, they will host your web site in their web
server along with several other web sites for a fee.
o HTTP is media independent: It specifies that any type of media content can be sent by HTTP as
long as both the server and the client can handle the data content.
o HTTP is connectionless: It is a connectionless approach in which HTTP client i.e., a browser
initiates the HTTP request and after the request is sent the client disconnects from server and waits
for the response.
o HTTP is stateless: The client and server are aware of each other during a current request only.
Afterwards, both of them forget each other. Due to the stateless nature of protocol, neither the client
nor the server can retain the information about different request across the web pages.
The Basic Architecture of HTTP (Hyper Text Transfer Protocol):
The below diagram represents the basic architecture of web application and depicts where HTTP
stands:
Texts between the BODY tag (<body> and </body>) will be displayed in or by the browser.
Basic Structure of an HTML Document
Here is an example shows the basic structure of an HTML document.
<!DOCTYPE html>
<html>
<head>
<title>This is Page Title</title>
</head>
<body>
</body>
</html>
To start HTML coding, open your text editor like Notepad for windows user. Type the above HTML
code or just do copy and paste.
After typing/copying, save it as filename.htm or filename.html in you computer. Now open saved
HTML document in a web browser to watch output webpage.
You will watch the following given HTML output webpage on your browser.
open Close
Description Example
tag tag
My name is
This tag allows you to Fred.
<p> </p>
create paragraphs I live in
Medway
<h1> </h1> This is the largest heading Heading 1
This is second biggest
<h2> </h2> Heading 2
heading
<h3> </h3> This is the next heading Heading 3
<h4> </h4> This is another heading Heading 4
This is the second smallest
<h5> </h5> Heading 5
heading
<h6> </h6> This is the smallest heading Heading 6
This is a horizontal line.
<hr
n/a You can use width and size
>
attributes
<b> </b> This makes text bold Bold text
<i> </i> This makes text italic Italic text
<br This tag allows you to abc
n/a
/> insert line breaks def
Syntax:
body
{
color:color name;
}
Example:Html
<!DOCTYPE html>
<html><head>
<style>
h1{
color:red;
h2{
color:gre
en;
</style></head>
<body>
<h
1>
AP
EC
</h1>
<h
2>
M
C
A
</h2>
</body>
</html>
2.TEXT ALIGNMENT
Text alignment property is used to set the horizontal alignment of the text.
The text can be set to left, right, centered and justified alignment.
In justified alignment, line is stretched such that left and right margins are straight.
Syntax:
body
{
text-align:alignment type;
}
Example:html
<!DOCTYPE html>
<html>
<head>
<sty
le>
h1
color:red;
text-align:center;
}
h2
{
color:gr’89
een; text-
align:left;
}
</style>
</head>
<body>
<h1>
</h1>
<h2>
TEXT FORMATTING
</h2>
</body>
</html>
3.TEXT-weight
The font-weight property sets the weight, or thickness, of a font and is dependent either
onavailable font faces within a font family or weights defined by the browser.
span {
font-weight: bold;
}
Prepared by. E.Janakiraman.MCA,Mphil,. AP/MCA Page 10
MC4201 – FULL STACK WEB DEVELOPMENT UNIT - 1
The font-weight property accepts either a keyword value or predefined numeric value.
Theavailable keywords are:
normal
bold
bolder
lighter
100
200
300
400
500
600
700
800
900
The keyword value normal maps to the numeric value 400 and the value bold maps to 700.
In order to see any effect using values other than 400 or 700, the font being used must
havebuilt-in faces that match those specified weights.
If a font has a bold (“700”) or normal (“400”) version as part of the font family, the
browserwill use that. If those are not available, the browser will mimic its own bold or
normal version of the font. It will not mimic the other unavailable weights. Fonts often
use names like “Regular” and “Light” to identify any alternate font weights.
The following demo demonstrates the use of the alternate weight values:
4.Text font
font-style
font-variant
font-weight
font-size/line-height
font-family
The font-size and font-family values are required. If one of the other values is missing,
theirdefault value are used
Property Values
Property/Value Description
font-size/line-height Specifies the font size and the line-height. Default value is "normal"
font-family Specifies the font family. Default value depends on the browser
Caption Uses the font that are used by captioned controls (like buttons, drop-
downs, etc.)
status-bar Uses the fonts that are used by the status bar
Initial Sets this property to its default value. Read about initial
Inherit Inherits this property from its parent element. Read about inherit
Example:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Output:
The border property of an image is used to set the width of an image border. This property can have a value
in length or in %.
A width of zero pixels means no border.
Here is the example −
<html>
<head>
</head>
<body>
<img style = "border:0px;" src = "C:\Users\JANAKIRAMAN\OneDrive\Desktop\1.png" />
<br />
<img style = "border:3px dashed red;" src =
"C:\Users\JANAKIRAMAN\OneDrive\Desktop\1.png" />
</body>
</html>
<html>
<head>
</head>
<body>
<br />
</body>
</html>
<body>
The element selector in CSS is used to select HTML elements which are required to bestyled.
In a selector declaration, there is the name of the HTML element and the CSS properties which
are to be applied to that element is written inside the brackets {}.
Syntax:
element {
\\ CSS property
}
Example :
<!DOCTYPE html>
<html>
<head>
<title>element selector</title>
<style>
h1 {
color:green;
text-align:center;
h2 {
text-align:center;
</style>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>element Selector</h2>
</body>
</html>
Output:
The .class selector is used to select all elements which belong to a particular class attribute. In
order to select the elements with a particular class, use the period (.) character specifying the
class name ie., it will match the HTML element based on the contents of their class attribute.
The class name is mostly used to set the CSS property to a given class.
Syntax:
.class {
// CSS property
}
Example : This example demonstrates the class Selector for the specific HTML element.
<!DOCTYPE html>
<html><head><style>
.geeks {
color: green;
.gfg {
background-color: yellow;
</style>
</head>
<body style="text-align:center">
<h1 class="geeks">GeeksforGeeks</h1>
<h2>.class Selector</h2>
<div class="gfg">
</div></body></html>
Output:
Example:
<!DOCTYPE html>
<html><head>
<title>#id selector</title>
<style>
#gfg1 {
color:green;
text-align:center;
#gfg2 {
text-align:center;
</style>
</head><body>
<h1 id = "gfg1">GeeksforGeeks</h1>
</body></html>
Output:
Example :
<!DOCTYPE html>
<html><head>
<title>* Selector</title>
<style>
* { color:green;
text-align:center;
</style>
</head><body>
<h2>*(Universal) Selector</h2>
<div>
<p>MBA</p>
<p>MCA</p>
</div>
<p>COMPUTER APPLICATION</p>
</body></html>
Output:
5.Group-selector:
This selector is used to style all comma separated elements with the same style.
style.css: The following code is used in the above HTML code using the group selector.
Suppose you want to apply common styles to different selectors, instead of writing rules
separately you can write them in groups as shown below.
#div-container, .paragraph-class, h1{color: white;
background-color: purple;font-family: monospace;
}
Example :
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>
Sample Heading
</h1>
</div>
<p class="paragraph-class">
Prepared by. E.Janakiraman.MCA,Mphil,. AP/MCA Page 25
MC4201 – FULL STACK WEB DEVELOPMENT UNIT - 1
Geeks
for
geeks is
a
compute
r science
</p>
</body>
</html>
Example:
.HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,
initial-scale=1.0" />
<title>CSS Flexbox</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div class="container">
<div class="item item-1">1</div>
<div class="item item-2">2</div>
<div class="item item-3">3</div>
<div class="item item-4">4</div>
</div>
</body>
</html>
This is our CSS code in which we will be styling the flex-container and flex-
item.
.CSS
.container {
border: 5px solid rgb(0, 0, 0);
background-color: rgb(245 197 221);
}
.item {
border: 5px solid rgb(0, 0, 0);
background-color: rgb(141, 178, 226);
margin: 10px;
padding: 20px;
height: 100px;
width: 100px;
font-weight: bold;
font-size: 45px;
}
Output:
From the above output, the items are aligned vertically, by default, and the
default display is block-level. The pink area is the container and the blue boxes
within it are the items.
flex-direction: It sets the direction of the flex container’s main axis and
specifies how items will be placed inside the container.
Syntax:
flex-direction: attribute value
Attribute Values:
row: Flex items are displayed horizontally along a row.
column: Flex items are displayed vertically along a column.
row reverse: Flex items are displayed horizontally along a row but in reverse
order.
column reverse: Flex items are displayed vertically along a column but in
reverse order.
Note: The display direction, by default, is row.
flex-wrap: It specifies whether the flex container will have a single line or have
multiple lines.
Syntax:
flex-wrap: attribute value
Attribute values:
nowrap (default): It specifies that the flex items will not wrap and will be laid
out in a single line. It may cause the flex container to overflow.
Prepared by. E.Janakiraman.MCA,Mphil,. AP/MCA Page 29
MC4201 – FULL STACK WEB DEVELOPMENT UNIT - 1
wrap: It specifies that the flex items will wrap if necessary, and will be laid out
in multiple lines.
wrap-reverse: It is the same as a wrap, but the flex items will wrap in reverse
order in this case.
initial: It represents the value specified as the property’s initial value.
inherit: It represents the computed value of the property on the element’s
parent.
What is JavaScript
JavaScript is a dynamic type language, means you don't need to specify type of
the variable because it is dynamically used by JavaScript engine. You need to
use var here to specify the data type. It can hold any type of values such as
numbers, strings etc.
Data Descriptio
Example
Types n
represents
'hello', "hello world!"
String textual
etc
data
an integer
or a
Number floating- 3, 3.234, 3e-2 etc.
point
number
an integer
with 90071992512474099
BigInt
arbitrary 9n , 1n etc.
precision
Any of
two
Boolean values: true and false
true or
false
a data type
whose
undefine
variable is let a;
d
not
initialized
denotes a
Null let a = null;
null value
data type
whose
instances let value =
Symbol
are unique Symbol('hello');
and
immutable
key-value
pairs of
Object let student = { };
collection
of data
Here, all data types except Object are primitive data types, whereas Object is
non-primitive.
JavaScript Variable
1. JavaScript variable
2. JavaScript Local variable
3. JavaScript Global variable
A JavaScript variable is simply a name of storage location. There are two types
of variables in JavaScript : local variable and global variable.
There are some rules while declaring a JavaScript variable (also known as
identifiers).
Example
1. <script>
2. var x = 10;
3. var y = 20;
4. var z=x+y;
5. document.write(z);
6. </script>
output:
30.
<script>
function abc(){
var x=10;//local variable
}
</script>
<script>
var data=200;//gloabal variable
function a(){
document.writeln(data);
}
function b(){
document.writeln(data);
}
a();//calling JavaScript function
b();
</script>
Output:
200 200
1.9 Functions
A function is a group of reusable code which can be called anywhere in your
program. This eliminates the need of writing the same code again and again. It
helps programmers in writing modular codes. Functions allow a programmer to
divide a big program into a number of small and manageable functions.
Like any other advanced programming language, JavaScript also supports all the
features necessary to write modular code using functions. You must have seen
functions like alert() and write() in the earlier chapters. We were using these
functions again and again, but they had been written in core JavaScript only once.
JavaScript allows us to write our own functions as well. This section explains
how to write your own functions in JavaScript.
Function Definition
Before we use a function, we need to define it. The most common way to define a
function in JavaScript is by using the function keyword, followed by a unique
function name, a list of parameters (that might be empty), and a statement block
surrounded by curly braces.
Syntax
The basic syntax is shown here.
<script type = "text/javascript">
<!--
function functionname(parameter-list)
{
statements
}
//-->
</script>
Example
Try the following example. It defines a function called sayHello that takes no
parameters −
<script type = "text/javascript">
<!--
function sayHello()
{
alert("Hello there");
}
//-->
</script>
Calling a Function
To invoke a function somewhere later in the script, you would simply need to
write the name of that function as shown in the following code.
<html>
<head>
<script type = "text/javascript">
function sayHello() {
document.write ("Hello there!");
}
</script>
</head>
<body>
<p>Click the following button to call the function</p>
<form>
<input type = "button" onclick = "sayHello()" value = "Say Hello">
</form>
<p>Use different text in write method and then try...</p>
</body>
</html>
1.10 Events
What is an Event ?
JavaScript's interaction with HTML is handled through events that occur when
the user or the browser manipulates a page.
When the page loads, it is called an event. When the user clicks a button, that
click too is an event. Other examples include events like pressing any key,
closing a window, resizing a window, etc.
Developers can use these events to execute JavaScript coded responses, which
cause buttons to close windows, messages to be displayed to users, data to be
validated, and virtually any other type of response imaginable.
Events are a part of the Document Object Model (DOM) Level 3 and every
HTML element contains a set of events which can trigger JavaScript Code.
Please go through this small tutorial for a better understanding HTML Event
Reference. Here we will see a few examples to understand a relation between
Event and JavaScript −
This is the most frequently used event type which occurs when a user clicks the
left button of his mouse. You can put your validation, warning etc., against this
event type.
Example
Try the following example.
<html>
<head>
<script type = "text/javascript">
<!--
function sayHello() {
alert("Hello World")
}
//-->
</script>
</head>
<body>
<p>Click the following button and see result</p>
<form>
<input type = "button" onclick = "sayHello()" value = "Say Hello" />
</form>
</body>
</html>
GET is basically used for just getting (retrieving) some data from the
server. Note: The GET method may return cached data.
POST can also be used to get some data from the server. However, the POST
method NEVER caches data, and is often used to send data along with the
request.
To learn more about GET and POST, and the differences between the two
methods, please read our HTTP Methods GET vs POST chapter.
The $.get() method requests data from the server with an HTTP GET request.
Syntax:
$.get(URL,callback);
The required URL parameter specifies the URL you wish to request.
The following example uses the $.get() method to retrieve data from a file on the
server:
Example
<!DOCTYPE html>
<html>
<head>
<script
src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
});
});
});
</script>
</head>
<body>
<button>Send an AJAX GET request to a page and get the result back</button>
</body>
</html>
The second parameter is a callback function. The first callback parameter holds
the content of the page requested, and the second callback parameter holds the
status of the request.
<%
response.write("This is some text from an external ASP file.")
%>
The $.post() method requests data from the server using an HTTP POST request.
Syntax:
$.post(URL,data,callback);
The required URL parameter specifies the URL you wish to request.
The optional data parameter specifies some data to send along with the request.
The following example uses the $.post() method to send some data along with the
request:
Example
$("button").click(function(){
$.post("demo_test_post.asp",
{
name: "ADHIPARASAKTHI ENGINEERING COLLEGE",
city: "MELMARUVATHUR"
},
function(data, status){
alert("Data: " + data + "\nStatus: " + status);
});
});
Then we pass in some data to send along with the request (name and city).
The third parameter is a callback function. The first callback parameter holds the
content of the page requested, and the second callback parameter holds the status
of the request.
<%
dim fname,city
fname=Request.Form("name")
city=Request.Form("city")
Response.Write("Dear " & fname & ". ")
Response.Write("Hope you live well in " & city & ".")
%>