WP Notes 2024 Mca
WP Notes 2024 Mca
<!DOCTYPE>
<html>
<body bgcolor=black>
<tr bgcolor=yellow><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td bgcolor=pink>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td bgcolor=red>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
</body>
</html>
Unit I
<tr bgcolor=yellow><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td bgcolor=pink>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td bgcolor=red>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
</body>
</html>
What are Cascading Style Sheets?
styles define how to display HTML elements;
MIME (Multipurpose Internet Mail Extensions)
The MIME tells what is in a message so that the message contents are
arranged or used in proper way.
The MIME protocol allows the users to exchange various types of digital
content such as pictures, audio, video, and various types of documents
and files in the e-mail.
Main_mime_type/mime_subtype
The type represents the general category into which the data type
video or text. The subtype identifies the exact kind of data of the
specified type the MIME type represents.
For example, for the MIME type text, the subtype might be plain (plain
text),html (HTML source code) files.
Network Virtual Terminal (NVT)
User agent is a small piece of data that is sent by your web browser when accessing a
website or application.
A browser's user agent string (UA) helps identify which browser is being used, what
version, and on which operating system.
Ex:
A GIF image for ex, has the following MIME type:
audio/mp3
text/css
video/mp4
text/html
Some of the commonly used MIME types
1. MIME-Version
MIME-Version header is used to indicate that the message is MIME formatted. This header
is having a value of “1.0” typically.
eg: MIME-Version: 1.0
2. Content-Type
This header is used to describe the content type of the message. The Content-Type header
includes the type and a sub-type parts.
3. Content-Disposition
The original MIME specifications only described the structure of mail messages
1) Inline Content-Disposition
2) Attachment Content-Disposition
Inline Content-Disposition
Attachment Content-Disposition
The Attachment Content-Disposition will not be displayed automatically. It needs the user
action to get opened and displayed.
4. Content-Transfer-Encoding
It indicates whether or not a binary-to-text encoding scheme has been used on top of the
original encoding as specified within the Content-Type header:
1) If such a binary-to-text encoding method has been used, it states which one.
2) If not, it provides a descriptive label for the format of content, with respect to the
presence of 8-bit or binary content.
History of HTML
<!DOCTYPE html>
The DOCTYPE tells the browser which type and version of document .
The <html> Element
<html lang="en">
The lang attribute in the <html> element declares which language the page
content is in.
Each of the world’s major languages has a two-character code, e.g. Spanish = "es", French =
"fr", German = "de", Chinese = "zh", Arabic = "ar".
HTML 5 Example
HTML 5 Tags
Forum post
Blog post
News story
<head>
<style>
article {
width: 300px;
border: 2px solid gray;
padding: 10px;
border-radius: 10px;
margin: 0 auto;
}
h1 {
color: green;
}
</style>
</head>
<body>
<article>
<img src= "https://media.geeksforgeeks.org/wp-content/cdn-uploads/20190710102234/download3.png"
alt="" width="300" height="250" class="alignnone size-medium wp-image-560930" />
<h1>GeeksforGeeks</h1>
</article>
</body>
</html>
Syntax
The <article> tag comes in pairs.
The content is written between the opening (<article>) and closing (</article>)
tags.
<canvas> It is used to draw canvas.
Canvas has several methods for drawing paths, boxes, circles, text,
and adding images.
Canvas Examples
and no content.
<audio controls>
Every browser understands this element even when we declare the element
using just the tag.
However, when we set focus on the input box (or hover over the box), you will
see that it is a spinner.
check if it allows us to enter non-numerical
values, such as alphabets.
Definition and Usage placeholder
With the Web Storage feature, web applications can locally store
data within the browser on the client or user side.
It will not send data to the server side, hence it is faster than cookies
storage.
The data stored by local Storage never expires, but cookies data
expires after some time or session.
Web storage is more secure, and large amounts of data can be stored
locally, without affecting website performance.
Unlike cookies, the storage limit is far larger (at most 5MB)
Cookies can store upto 4kb data in string type, whereas HTML5 web
storage can store 5mb, (Upto 10mb in some browsers) data in key-
value pair.
Types of Web Storage
1. HTML5 Local Storage
The data will not be deleted when the browser is closed, and will be available
the next day, week, or year.
You will put the data and it will still be there when you close the browser.
Session storage will lose the data as soon as you will close the browser. As
the session is going to end.
The session Storage object is equal to the local Storage object, except that it
stores the data for only one session. The data is deleted when the user
closes the specific browser tab.
stores data for one session (data is lost when the browser tab is closed)
Local Storage: Local Storages uses Windows.localStaorage object
which stores data and available for every page.
First parameter is name, and second is value. We can also add local storage
using localstorage.key=value;
object
property
This is nothing but the Session storage once this browser is
closed the session is expired.
The Web Workers are the separate JavaScript code which runs in the
background of the web page without affecting the user Interface.
Everyone wants a website or application which work fast and can execute
multiple operations simultaneously without affecting the performance of the
page.
When executing scripts in an HTML page, the page becomes unresponsive until
the script is finished.
•Web worker threads communicate with each other using postMessage() callback
method
Web Workers are the multithreaded object which can
execute multiple JavaScript in parallel without affecting the
performance of the application or webpage.
worker.terminate();
HTML Drag and Drop (DnD) is a feature of HTML5.
What to Drag → draggable="true“
Where to Drop
event.preventDefault() method
Do the Drop
the data type is "text" and the value is the id of the draggable element ("drag1").
Where to Drop – ondragover event
The ondragover event specifies where the dragged data can be
dropped.
Ex:
<p draggable="true“ ondragstart="Function1(event)">Drag!</p>
ondrop Event
The ondrop event occurs when a draggable selection is dropped on
a target.
ondrag Event
Property or attribute
What is a Scripting Language?
This means that the script is run by the client's web browser, and the
resulting HTML is displayed in the browser.
The code runs on the client’s computer’s browser either while the
web page is loading or after it has finished loading.
The client refers to the script that runs on the user’s computer
system.
The following are the most popular client-side scripting languages:
3.Query: jQuery is a JavaScript library that is fast, tiny, and lightweight. It’s used to
turn a lot of JavaScript code into user-friendly functionality.
4.HTML: Basic and easiest, HTML is used to provide the basic framework for web
designing.
5.CSS: Provides a way to do high dynamic graphic design to make web applications
more attractive and interesting for the end-user.
1. Client-Side Scripting
Client-Side scripting is used to make changes in the web page after they arrive at the
browser.
It is useful for making the pages a bit more interesting and user-friendly. It provides
The page is displayed on the browser with any scripts running during or after the
display.
Client-Side scripting is used to make web page changes after they arrive at the
browser.
These scripts rely on the user's computer. If the computer is slow, then they
may run slow.
These scripts may not run at all if the browser does not understand the
scripting language.
The client requests a web page from the server.
The script in the page is interpreted by the server, creating or changing the page
content to suit the user (client) and the passing data around.
The page in its final form is sent to the user(client) and then cannot be changed
using Server-Side Scripting.
Server-Side Scripting tends to be used for allowing the users to have individual
accounts and provides data from the databases.
Server-Side script runs on the server and generate results which are sent to the user.
Running all the scripts puts a lot of load onto a server but not on the user's system.
Server-side scripting refers to the execution of scripts on a server,
which can generate dynamic HTML pages.
This means that the script is run on the server, and the resulting
HTML is sent to the client.
The server-side environment runs a scripting language which is called a web server.
It is different from Client-Side Scripting where the scripts are run by viewing the
web browser, usually in JavaScript.
It is used for allowing the users to have individual accounts and providing data from
databases.
4. Versatile:
•Scripting languages are very versatile they can be used for different purposes.
•It can be used for web development, scientific study, administration, and
analysis.
5. Easy to learn:
•One of the major benefits of scripting language is that it is easy to learn when
compared to programming languages.
.
Examples of popular scripting languages: server-side
Interpreted language.
It is a case-sensitive language.
It is a case-sensitive language.
Programming logic for interaction with
the user, to handle events, etc.
Behavior
(JAVA SCRIPT)
CONTENT
(HTML) HTML defines Web sites content through
tags (headings, paragraphs, lists, …)
Java script comment
Less coding: It makes our program compact. We don’t need to write many
lines of code each time to perform a common task.
JavaScript Function Syntax
parameter2, ...)
1. Document Node:
- The root node of the DOM tree, representing the entire HTML or XML
document.
- Methods:
- `getElementById(id)`: Retrieves an element with the specified `id`
attribute.
- `getElementsByTagName(tagName)`: Retrieves a collection of
elements with the specified tag name.
- Methods:
3. Text Node: - Represents the text content within an element. - Accessible through the `nodeValue`
property of an element. - Methods: - `splitText(offset)`: Splits the text node into two separate text
nodes at the specified offset
4. Attribute Node:
- Represents an attribute of an HTML or XML element.
- Accessible through the `getAttribute(name)` and `setAttribute(name,
value)` methods of the element node.
5. Comment Node:
- Represents an HTML or XML comment within the document.
- Accessible through the `Node.COMMENT_NODE` property.
8. Creating and Modifying Nodes: - The DOM provides methods for creating new nodes and
modifying existing nodes.
- Methods: - `createElement(tagName)`: Creates a new element node with the specified tag
name.
- `createTextNode(text)`: Creates a new text node with the specified text content. -
`createAttribute(name)`: Creates a new attribute node with the specified name. -
`appendChild(node)`: Appends a child node to the current node. - `removeChild(node)`:
Removes a child node from the current node. - `replaceChild(newNode, oldNode)`: Replaces
an existing child node with a new node.
9. Event Handling:
- The DOM allows you to attach event listeners to nodes to handle
various events.
- Methods:
- `addEventListener(event, callback)`: Attaches an event listener to
the
node.
- `removeEventListener(event, callback)`: Removes an event
listener
from the node
With the HTML DOM, JavaScript can access and change all the elements of an
HTML document.
HTML DOM Document URL
The URL property returns the full URL of the document.
The activeElement property returns the HTML element
that have focus.
<!DOCTYPE html>
<html>
<body onclick="myFunction()">
<p id="demo"></p>
<script>
function myFunction() {
const element = document.activeElement.tagName;
document.getElementById("demo").innerHTML = element;
}
</script>
</body>
</html>
HTML DOM Document addEventListener()
<p id="demo"></p>
<script>
document.addEventListener("click", function(){
document.getElementById("demo").innerHTML = "Hello World!";
});
</script>
</body>
</html>
HTML DOM Document documentElement
getElementById method
In order to access an element by class name we have another method
querySelector() method.
This method returns web page elements by its class name, tag name.
Accessing and Modifying the DOM
Logical structure of the tree DOM :
object
Element object
nodeType
Certainly! Event handlers in HTML allow you to associate JavaScript code with
specific events that occur on HTML elements. They provide a way to respond to user
interactions or other events happening on the webpage. Event handlers can be
added directly as HTML attributes or attached dynamically using JavaScript. Here are
the key aspects of event handlers in HTML: 1. HTML Attribute Event Handlers: - Event
handlers can be added directly to HTML elements using attributes. - The attribute
name follows the format "on{event}", where {event} is the name of the event in
lowercase. - The attribute value contains JavaScript code that will be executed when
the event occurs.
2. JavaScript Event Handlers:
- Event handlers can also be attached dynamically using JavaScript.
- The `addEventListener()` method is used to bind an event handler to an
element.
- This method takes the event name and a callback function as
parameters.
- The callback function is executed when the specified event occurs on
the element.
3. Event Object:
- When an event occurs, an event object is created and passed as an
argument to the event handler function.
- The event object contains information about the event and provides
methods and properties to interact with it.
- It allows you to access event-specific details such as the target element,
event type, coordinates, and more.
What is Event propagation
The Event Propagation determines in which order
the elements receive the event.
1.Event Bubbling
2.Event Capturing
Event Bubbling
It's also the same thing with the div and the body.
When you click the button, it's just like you're also clicking the span, div, and body because
they are the button's ancestors. This is the idea of event bubbling.
An event doesn't stop at the direct element that receives it.
You have assigned a onclick event handler on a hyperlink (i.e. <a> element) which is
nested inside a paragraph (i.e. <p> element).
They travel up and down through the DOM tree to reach their target. This is known as
event propagation
HTML DOM Document addEventListener()
But a handler can also take decision to stop the bubbling when the
event has been processed completely.
• <body>
• <div id="p1">
• <button id="c1" onclick="event.stopPropagation()"> child</button>
• </div>
• <script>
event.stopImmediatePropagation () method.
It means when the user click on the
button, the click event flows in this order
from bottom to top.
Event Capturing
Event Capturing is opposite to event bubbling, where in event
capturing, an event moves from the outermost element to the
target.
This means after the web server has processed the client request for a web page,
the web server will not remember anything about the client that made the
request.
Means after the web server has processed the initial client request ,it does not
remember anything about the settings the client made.
What are Cookies?
Cookies are small text files or a set of information(data) that is
stored on the user’s system or browser..
Cookies let you store user information in web pages. You can store,
document.cookie property
During the browsing session, browser stores the cookies in memory, at the
time of quitting they goto the file called cookies.txt.
The first two parts i.e. name and value are required and rest
parts are optional.
1. name and value
The first part of the cookie string must have the name and value.
document.cookie = "myName=George";
2.
Expires
To give more life to the cookies you must set an expiration date in the following
format.
Here is an example where the cookie will live upto Mon, 12 Jun 2023:00:00:00
GMT
Usually, the path is set to root level directory ( '/' ) , which means the cookie is
available for all the pages of your site.
If you want the cookie to be readable in a specific directory called php, add path=/php;.
Cookie domain attribute
Here, the cookie is valid for the given domain and all its sub-domains.
domain=training.javatpoint.com
Here, the cookie is valid only for the given sub-domain. So, it's a better
approach to provide domain name instead of sub-domain.
Secure
The last part of the cookie string is the secure part which is a
Boolean value.
If the cookie is marked secure (i.e. secure value is true) then the
cookie will be sent to web server and try to retrieve it using a
secure communication channel.
ReactJS is a efficient, and flexible JavaScript library for building reusable UI components.
The main objective of ReactJS is to develop User Interfaces (UI) that improves the
speed of the apps.
So each time there is a change in the state of our application, virtual DOM gets updated
first instead of the real DOM.
Whenever there is any change in the state of the application UI,
DOM is updated and represents the change.
Every change for updating the application User Interface, which
affects the performance and slows it down.
For example, the real and virtual DOM is represented as a tree structure.
A node is added to the tree when a new item is added to the application UI.
Virtual Document Object Model(VDOM)
Reason why react works faster because it uses virtual DOM concept.
Finally, it updates only part of the DOM where these changes are
required.
The JavaScript virtual DOM is faster than the regular DOM.
For example, class becomes className in JSX, and tabindex becomes tabIndex
.
Handling events with React elements is very similar to handling events on DOM
elements. There are some syntax differences:
Another difference is that you cannot return false to prevent default behavior in React.
In react, we cannot return false to prevent the default behavior
For one, with React, we have to name events using the camelCase
notation.
Synthetic events are cross-browser wrappers around the browser’s original events.
A cross-browser wrapper is a concept used in web development to ensure consistent behavior across
different web browsers.
cross-browser wrappers
This means the browsers may display the same Web page with slightly
different page and text formatting. Since not all browsers support the
same HTML tags
An event listener
An event handler
To listen for events and detect them, we have to specify the event
listener attribute on the React/JSX element. The general form of this
attribute is:
Apache
Web pages
Are a collection of data, including images, text files, hyperlinks,
database files etc., all located on some computer (also known as
server space) on the Internet.
When any user requests their web browser to run any web page, the
webserver places all the data materials together into an organized
web page and forwards them back to the web browser with the help
of the Internet. Therefore, we can conclude that: -
HTTP PROTOCOL
Collection of web pages
Web Server
web sites
• Web server is a computer system that hosts
• Runs web server software Ex: Apache HTTP, Microsoft
• Connected to internet IIS
When Apache is running under Unix, its process name is httpd , which is short for
"HTTP daemon/service".
HTTPd waits for the incoming client requests and for each request it answers
by replying with requested information.
It listens to one or more TCP ports (usually port 80) for incoming requests
from browsers and serves the requested files accordingly.
It waits for requests from the web and forwards the request to the
appropriate processes.
When used like this it will create a pool of child processes or threads to handle
requests.
When this daemon used, it will create threads or a pool of child processes to
handle requests.
▪ Example:
<form method="GET" action=“example.php">
</form>
▪ When that form is submitted, the HTTP request begins
like this:
▪ GET/example.php?first_name=John &last_name=Doe
&action=Submit HTTP/1.1
POST: Send Data to the Server
▪ POST requests are most commonly sent by web forms
▪ POST method requests can also be made via AJAX, applications, URL, etc.
Example:
<form method="POST" action=“example.php">
</form>
Submitting that form creates an HTTP request like this:
Output:
first_name=John &last_name=Doe &action=Submit
Response Message: The response message is sent by the server to the client that
consists of a status line, headers, and sometimes a body.
General Header
Request Header
Response Header
Entity Header
HTTP RESPONSE STRUCTURE
HTTP Status Codes
▪ 200's are used for successful requests.
1. General Header:
Contains information about the request such as the URL that you have
requested, the method(GET, POST, HEAD) ,the browser used to
generate the request and other info.
3. Response Header:
Server: IIS
Most of the sites usually hide their server information.
4. Entity Header
AJAX
It is a group of inter-related technologies like JavaScript,
DOM, XML, HTML/XHTML, CSS,
XMLHttpRequest
DOM
•It is used for dynamic display and interaction with data. alter the
content and how it is displayed.
XML or JSON
which is used to transfer data between the server and Web browser (using XML) JSON (Javascript
Object Notation) is like XML but short and faster than XML.
XMLHttpRequest
It’s a object, For asynchronous communication between client and server.
JavaScript
It is used to bring above technologies together.
Brower's javascript
engine is blocked.
The original article that defined the term AJAX lists the following
technologies:
•XHTML and CSS, which defines what is being displayed and how it is
displayed.
•XML and XSLT, which is used to transfer data between the server and Web
browser (using XML), and to manipulate that data (using XSLT).
By JS
Thes server
processes
the request
All modern browsers (Chrome, Firefox, Edge , Safari, Opera
have a built-in XMLHttpRequest object.
output
It does not actually open the file or Web resource requested by the method.
Rather, it sets up a request for a file.
OUTPUT
AJAX - Server Response
This can substantially reduce the amount of bandwidth that the Web
application requires.
• Ajax (Asynchronous JavaScript And XML) and RSS (Really Simple Syndication)
or (Rich site summary) are two technologies.
using Ajax, we are passing over the work of processing the RSS
XML file to the web browser, thus reducing server load. Also,
because we are able to fetch the entire RSS XML file from the
server without having to refresh the page.
3. This function is responsible for fetching the specified RSS XML file
from the server.
Selects file
fetches name of the
successful RSS feed
It contains a simple HTML form and a link to a
JavaScript:
Every time an option is selected in the input field this function executes the
following:
Adds a parameter (q) to the url with the selected option from the drop down box
Adds a random number to prevent the server from using a cached file
AJAX Advanced
Cross-Origin Resource Sharing (CORS)
What is CORS?
There's a security policy that browsers follow.
example.com can retrieve data from its server at example.com because they share
the same domain.
SERVER
Originating
How does CORS work?
Simple requests:
A CORS request that doesn’t need to go through any preflight requests (initial
checks) is referred to as a simple request.
•AJAX request is started by a browser tab that is open to
https://www.mydomain.com. GET widgets at https://api.mydomain.com
•The browser automatically inserts the Origin Request Header along with headers
like Host for cross-origin requests
•The Origin request header is examined by the server. The Access-Control-Allow-
Origin is set to the value in the request header Origin if the Origin value is allowed.
•The Access-Control-Allow-Origin header is checked by the browser to verify if it
matches the origin of the tab when it receives the answer. If not, the reply is
suppressed.
Preflighted requests:
The other kind of CORS request is a preflighted request.
A preflighted request is a CORS request in which the browser must first make a
preflight request (also known as a preliminary ) to the server to determine
whether the original CORS request can be processed.
The browser performs this for every unsafe request that is intended to alter data
— for example, POST, PUT, or DELETE requests.
jQuery makes event handling, DOM manipulation, Ajax calls much easier
than JavaScript
AJAX is the art of exchanging data with a server, and updating parts of a web page
- without reloading the whole page.
With the jQuery AJAX methods, you can request text, HTML, XML, or JSON from a
remote server using both HTTP Get and HTTP Post - And you can load the external
data directly into the selected HTML elements of your web page!
jQuery is a JavaScript Library. cross-platform
The main purpose of jQuery is to provide an easy way to use JavaScript on your website to make it
more interactive and attractive. It is also used to add animation.
Many of the biggest companies on the Web use jQuery, such as:
Google
Microsoft
IBM
Netflix
what is the need of jQuery or what difference it makes on bringing jQuery instead of AJAX/
JavaScript
jQuery - AJAX load() Method
the browser must wait for the script to download, execute the downloaded
script, and only then can it process the rest of the page.
But how can I connect(objects) cat with pet? I can make pet a
prototype object for cat!
Following the example,
2
Parrot
Parrot 2
Parrot 2 2
Parrot
Parrot
Parrot
Parrot
A Regular expression is a string that describes a pattern
e.g., email addresses and phone numbers.
Regular expressions are useful for searching and replacing strings that match a pattern.
Self-describing data is the data that describes both its content and
structure.
HI
The root element in the example is <bookstore>. All elements in the
document are contained within <bookstore>.
The <book> element has 4 children: <title>,< author>, <year> and <price>.
XML parsers are also known as XML Processor .
For reading the content and write the contents into the XML file W3C organization
have provided some programs. Those programs are called as parsers.
XML parser validates the document and check that the document is well
formatted.
Parsers are the programs which are meant for manipulating the data on the
XML file.
The goal of a parser is to transform XML into a readable code. transforming
it into a readable format for applications and systems to use
Two different parsers :
SAX (Simple API for XML)
1. Simple API for XML(Read only parser which is used for reading the content
from an XML file. This API is an event based API
It is preferred for larger documents. (because it will not occupy much memory)
2. DOM parser used for performing all kinds of manipulations on XML files.
Both JSON and XML can be used to receive data from a web server
Java Script has a built in function for converting JSON strings into
Java Script objects.
JSON.parse()
JSON and XML examples both define an employees object, with
an array of 3 employees:
XML has to be parsed with an XML parser. JSON can be parsed by a
standard JavaScript function.
Both JSON and XML can be fetched with an XMLHttpRequest
AJAX RSS Feeds