Full Stack Development Unit-1
Full Stack Development Unit-1
lOMoARcPSD|30616144
Introduction to Web:
Web consists of billions of clients and server connected through wires and wireless
networks.
The web clients make requests to web server.
The web server receives the request, finds the resources and return the response to the
client.
When a server answers a request, it usually sends some type of content to the client.
The client uses web browser to send request to the server.
The server often sends response to the browser with a set of instructions written in
HTML(Hypertext Markup Language).
All browsers know how to display HTML page to the client.
Server - Client
A server is simply a computer that provides the network resources and provides service to other
computers when they request it.
A client is the computer running a program that requests the service from a server. Local area
network (LAN) is based on client server network relationship.
be used for other purposes as well using extensions of its request methods, error codes, and
headers.
Basically, HTTP is a TCP/IP based communication protocol, that is used to deliver data
(HTML files, image files, query results, etc.) on the World Wide Web. The default port is TCP
80, but other ports can be used as well. It provides a standardized way for computers to
communicate with each other.
Basic Features
HTTP is connectionless: The HTTP client, i.e., a browser initiates an HTTP request and
after a request is made, the client waits for the response. The server processes the request
and sends a response back after which client disconnect the connection. So client and
server knows about each other during current request and response only. Further requests
are made on new connection like client and server are new to each other.
HTTP is media independent: It means, any type of data can be sent by HTTP as long as
both the client and the server know how to handle the data content. It is required for the
client as well as the server to specify the content type using appropriate MIME-type.
HTTP is stateless: As mentioned above, HTTP is connectionless and it is a direct result
of HTTP being a stateless protocol. The server and client are aware of each other only
during a current request. Afterwards, both of them forget about each other. Due to this
nature of the protocol, neither the client nor the browser can retain information between
different requests across the web pages.
HTTP/1.0 uses a new connection for each request/response exchange, where as HTTP/1.1
connection may be used for one or more request/response exchanges.
Basic Architecture
The following diagram shows a very basic architecture of a web application and depicts where
HTTP sits:
lOMoARcPSD|30616144
The HTTP protocol is a request/response protocol based on the client/server based architecture
where web browsers, robots and search engines, etc. act like HTTP clients, and the Web server
acts as a server.
Client
The HTTP client sends a request to the server in the form of a request method, URI, and protocol
version, followed by a MIME-like message containing request modifiers, client information, and
possible body content over a TCP/IP connection.
Server
The HTTP server responds with a status line, including the message's protocol version and a
success or error code, followed by a MIME-like message containing server information, entity
meta information, and possible entity-body content.
HTTP - Requests
An HTTP client sends an HTTP request to a server in the form of a request message which
includes following format:
A Request-line
Zero or more header (General|Request|Entity) fields followed by CRLF
An empty line (i.e., a line with nothing preceding the CRLF) indicating the end of the
header fields
Optionally a message-body
Request-Line
The Request-Line begins with a method token, followed by the Request-URI and the protocol
version, and ending with CRLF. The elements are separated by space SP characters.
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
Request Method
The request method indicates the method to be performed on the resource identified by the
given Request-URI. The method is case-sensitive and should always be mentioned in uppercase.
The following table lists all the supported methods in HTTP/1.1.
1 GET - The GET method is used to retrieve information from the given server using a
given URI. Requests using GET should only retrieve data and should have no other effect
on the data.
2 HEAD - Same as GET, but it transfers the status line and the header section only.
lOMoARcPSD|30616144
3 POST - A POST request is used to send data to the server, for example, customer
information, file upload, etc. using HTML forms.
A Status-line
Zero or more header (General|Response|Entity) fields followed by CRLF
An empty line (i.e., a line with nothing preceding the CRLF)indicating the end of the
header fields
Optionally a message-body
Message Status-Line
A Status-Line consists of the protocol version followed by a numeric status code and its
associated textual phrase. The elements are separated by space SP characters.
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
HTTP Version
A server supporting HTTP version 1.1 will return the following version
information: HTTP-Version = HTTP/1.1
Status Code
The Status-Code element is a 3-digit integer where first digit of the Status-Code defines the class
of response and the last two digits do not have any categorization role. There are 5 values for the
first digit:
1 1xx: Informational - It means the request was received and the process is continuing.
2 2xx: Success - It means the action was successfully received, understood, and accepted.
3 3xx: Redirection - It means further action must be taken in order to complete the request.
lOMoARcPSD|30616144
HEAD: This contains the information about the HTML document. For Example, the Title of
the page, version of HTML, Meta Data, etc.
BODY: This contains everything you want to display on the Web Page.
<html> </html> : <html> is a root element of html. It’s a biggest and main element in
complete html language, all the tags , elements and attributes enclosed in it or we can say wrap
init , which is used to structure a web page.
<head>: Head tag contains metadata, title, page CSS etc. Data stored in the <head> tag is not
displayed to the user, it is just written for reference purposes and as a watermark of the owner.
<body>: A body tag is used to enclose all the data which a web page has from texts to links. All
the content that you see rendered in the browser is contained within this element. Following tags
and elements used in the body.
1 . <h1> ,<h2> ,<h3> to <h6>
2. <p>
3. <div> and <span>
4. <b>, <i> and<u>
5. <li>,<ul>and<ol>.
6. <img> , <audio> , <video> and<iframe>
7. <table> <th> , <thead>and<tr>.
8. <form>
9. <label> and <input> others……….
Basic Markup tags
Tag Description
<!DOCTYPE> Defines the document type
<html> Defines an HTML document
<head> Contains metadata/information for the document
<title> Defines a title for the document
lOMoARcPSD|30616144
Text Color
The color property is used to set the color of the text. The color is specified by:
Program:
<!DOCTYPE html>
<html>
<head>
<style>
body
{
color: blue;
}
h1
{
color: green;
}
</style>
</head>
<body>
<h1>This is heading 1</h1>
<p>This is an ordinary paragraph. Notice that this text is blue. The default text color for a page is
defined in the body selector.</p>
<p>Another paragraph.</p>
</body>
</html>
CSS Text Alignment and Text Direction
The CSS Text Alignment/Direction Properties
Property Description
direction Specifies the text direction/writing direction
text-align Specifies the horizontal alignment of text
text-align- last Specifies how to align the last line of a text
lOMoARcPSD|30616144
unicode- bidi Used together with the direction property to set or return whether the text should be
overridden to support multiple languages in the same document
Text Alignment
Program:
<html>
<head>
<style>
h1 {
text-align: center;
}
h2
{
text-align: left;
}
h3
{
text-align: right;
}
</style>
</head>
<body>
<h1>Heading 1 (center)</h1>
<h2>Heading 2 (left)</h2>
<h3>Heading 3 (right)</h3>
<p>The three headings above are aligned center, left and right.</p>
</body>
</html>
CSS Text Decoration
Program:
<html>
<head>
<style>
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
lOMoARcPSD|30616144
p.ex {
text-decoration: overline underline;
}
</style>
</head>
<body>
</body>
</html>
Property Description
text-decoration Sets all the text-decoration properties in one declaration
CSS Images
CSS plays a good role to control image display. You can set the following image properties using
CSS.
The border property is used to set the width of an image border.
The height property is used to set the height of an image.
The width property is used to set the width of an image.
The -moz-opacity property is used to set the opacity of an image.
lOMoARcPSD|30616144
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.
<html>
<head>
</head>
<body>
<img style = "border:0px;" src = "/css/images/logo.png" />
<br />
<img style = "border:3px dashed red;" src = "/css/images/logo.png" />
</body>
</html>
The height property of an image is used to set the height of an image. This property can have a
value in length or in %. While giving value in %, it applies it in respect of the box in which an
image is available.
The width property of an image is used to set the width of an image. This property can have a
value in length or in %. While giving value in %, it applies it in respect of the box in which an
image is available
The -moz-opacity property of an image is used to set the opacity of an image. This property is
used to create a transparent image in Mozilla.
CSS Selectors
CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to style.
<!DOCTYPE html>
<html>
<head>
<style>
p
{
text-align: center;
color: red;
}
</style>
</head>
<body>
<p>Every paragraph will be affected by the style.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
To select elements with a specific class, write a period (.) character, followed by the class name.
Example
In this example all HTML elements with class="center" will be red and center-aligned:
.center {
text-align: center;
color: red;}
Example
The CSS rule below will affect every HTML element on the page:
*{
text-align:
center;
color: blue;}
Look at the following CSS code (the h1, h2, and p elements have the same style definitions):
h1 {
text-align: center; color:
red;}
h2 {
text-align:
center;
color: red;}
p{
text-align: center; color:
red;
}
CSS Flexbox Layout Module
Before the Flexbox Layout module, there were four layout modes:
The Flexible Box Layout Module, makes it easier to design flexible responsive layout structure
without using float or positioning.
Flexbox Elements
To start using the Flexbox model, you need to first define a flex container.
<!DOCTYPE html>
<html>
<head>
<style>
.flex-container {
display: flex;
background-color: DodgerBlue;
}
.flex-container > div {
background-color: #f1f1f1;
margin: 10px;
padding: 20px;
font-size: 30px;
}
</style>
</head>
<body>
<h1>Create a Flex Container</h1>
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>
<p>A Flexible Layout must have a parent element with the <em>display</em> property set to
<em>flex</em>.</p>
<p>Direct child elements(s) of the flexible container automatically becomes flexible items.</p>
</body>
</html>
Output:
items.
const x = 5;
const y = "Hello";
Here,
5 is an integer data.
"Hello" is a string data.
JavaScript String
JavaScript Number
Number represents integer and floating numbers (decimals and exponentials). For
example,
const number1 = 3;
const number2 = 3.433;
const number3 = 3e5 // 3 * 10^5
JavaScript Boolean
This data type represents logical entities. Boolean represents one of two
values: true or false . It is easier to think of it as a yes/no switch. For example,
Javascript Variables:
4 Ways to Declare a JavaScript Variable:
Using var
Using let
Using const
Using nothing
In this example, x, y, and z, are variables, declared with the var keyword:
Example
var x= 5;
var y= 6;
var z = x + y;
Declaring a JavaScript Variable
Creating a variable in JavaScript is called "declaring" a variable. You declare a JavaScript variable with
the var or the let keyword:
var carName;
To assign a value to the variable, use the equal sign:
carName = "Volvo";
Start the statement with let and separate the variables by comma:
Example
let person = "John Doe", carName = "Volvo", price = 200;
JavaScript Functions
A JavaScript function is a block of code designed to perform a particular
Example:
Function names can contain letters, digits, underscores, and dollar signs (same rules as variables).
Function Invocation
The code inside the function will execute when "something" invokes (calls) the function:
Function Return
When JavaScript reaches a return statement, the function will stop executing.
If the function was invoked from a statement, JavaScript will "return" to execute the code after the
invoking statement.
Functions often compute a return value. The return value is "returned" back to the "caller":
Example
Calculate the product of two numbers, and return the result:
function myFunction(a, b) {
return a * b; // Function returns the product of a and b
}
12
Why Functions?(Advantages)
You can reuse code: Define the code once, and use it many times.
You can use the same code many times with different arguments, to produce different results.
Local Variables
Variables declared within a JavaScript function, become LOCAL to the function.
onmouseout The user moves the mouse away from an HTML element
onkeydown The user pushes a keyboard key
onload The browser has finished loading the page
<!DOCTYPE html>
<html>
<body>
<script>
function displayDate() {
document.getElementById("demo").innerHTML = Date();
}
</script>
<p id="demo"></p>
</body>
</html>
JavaScript HTML Events
Click the button to display the date.