Features of HTTP:: Hypertext Transfer Protocol
Features of HTTP:: Hypertext Transfer Protocol
Features of HTTP:
o Connectionless protocol: HTTP is a connectionless protocol. HTTP client
initiates a request and waits for a response from the server. When the server
receives the request, the server processes the request and sends back the
response to the HTTP client after which the client disconnects the connection.
The connection between client and server exist only during the current
request and response time only.
o Media independent: HTTP protocol is a media independent as data can be
sent as long as both the client and server know how to handle the data
content. It is required for both the client and server to specify the content
type in MIME-type header.
o Stateless: HTTP is a stateless protocol as both the client and server know
each other only during the current request. Due to this nature of the protocol,
both the client and server do not retain the information between various
requests of the web pages.
HTTP Transactions
The above figure shows the HTTP transaction between client and server. The client
initiates a transaction by sending a request message to the server. The server
replies to the request message by sending a response message.
Messages
HTTP messages are of two types: request and response. Both the message types
follow the same message format.
Request Message: The request message is sent by the client that consists of a
request line, headers, and sometimes a body.
Response Message: The response message is sent by the server to the client that
consists of a status line, headers, and sometimes a body.
FTP
o FTP stands for File transfer protocol.
o FTP is a standard internet protocol provided by TCP/IP used for transmitting
the files from one host to another.
o It is mainly used for transferring the web page files from their creator to the
computer that acts as a server for other computers on the internet.
o It is also used for downloading the files to computer from other servers.
Objectives of FTP
o It provides the sharing of files.
o It is used to encourage the use of remote computers.
o It transfers the data more reliably and efficiently.
Why FTP?
Although transferring files from one system to another is very simple and
straightforward, but sometimes it can cause problems. For example, two systems
may have different file conventions. Two systems may have different ways to
represent text and data. Two systems may have different directory structures. FTP
protocol overcomes these problems by establishing two connections between hosts.
One connection is used for data transfer, and another connection is used for the
control connection.
Mechanism of FTP
The above figure shows the basic model of the FTP. The FTP client has three
components: the user interface, control process, and data transfer process. The
server has two components: the server control process and the server data transfer
process.
FTP Clients
o FTP client is a program that implements a file transfer protocol which allows
you to transfer files between two hosts on the internet.
o It allows a user to connect to a remote host and upload or download the files.
o It has a set of commands that we can use to connect to a host, transfer the
files between you and your host and close the connection.
o The FTP program is also available as a built-in component in a Web browser.
This GUI based FTP client makes the file transfer very easy and also does not
require to remember the FTP commands.
Advantages of FTP:
o Speed: One of the biggest advantages of FTP is speed. The FTP is one of the
fastest way to transfer the files from one computer to another computer.
o Efficient: It is more efficient as we do not need to complete all the
operations to get the entire file.
o Security: To access the FTP server, we need to login with the username and
password. Therefore, we can say that FTP is more secure.
o Back & forth movement: FTP allows us to transfer the files back and forth.
Suppose you are a manager of the company, you send some information to
all the employees, and they all send information back on the same server.
Disadvantages of FTP:
o The standard requirement of the industry is that all the FTP transmissions
should be encrypted. However, not all the FTP providers are equal and not all
the providers offer encryption. So, we will have to look out for the FTP
providers that provides encryption.
o FTP serves two operations, i.e., to send and receive large files on a network.
However, the size limit of the file is 2GB that can be sent. It also doesn't allow
you to run simultaneous transfers to multiple receivers.
o Passwords and file contents are sent in clear text that allows unwanted
eavesdropping. So, it is quite possible that attackers can carry out the brute
force attack by trying to guess the FTP password.
o It is not compatible with every system.
SMTP
o SMTP stands for Simple Mail Transfer Protocol.
o SMTP is a set of communication guidelines that allow software to transmit an
electronic mail over the internet is called Simple Mail Transfer Protocol.
o It is a program used for sending messages to other computer users based on
e-mail addresses.
o It provides a mail exchange between users on the same or different
computers, and it also supports:
o It can send a single message to one or more recipients.
o Sending message can include text, voice, video or graphics.
o It can also send the messages on networks outside the internet.
o The main purpose of SMTP is used to set up communication rules between
servers. The servers have a way of identifying themselves and announcing
what kind of communication they are trying to perform. They also have a way
of handling the errors such as incorrect email address. For example, if the
recipient address is wrong, then receiving server reply with an error message
of some kind.
Components of SMTP
o First, we will break the SMTP client and SMTP server into two components
such as user agent (UA) and mail transfer agent (MTA). The user agent (UA)
prepares the message, creates the envelope and then puts the message in
the envelope. The mail transfer agent (MTA) transfers this mail across the
internet.
o SMTP allows a more complex system by adding a relaying system. Instead of
just having one MTA at sending side and one at receiving side, more MTAs
can be added, acting either as a client or server to relay the email.
o The relaying system without TCP/IP protocol can also be used to send the
emails to users, and this is achieved by the use of the mail gateway. The mail
gateway is a relay MTA that can be used to receive an email.
Working of SMTP
1. Composition of Mail: A user sends an e-mail by composing an electronic
mail message using a Mail User Agent (MUA). Mail User Agent is a program
which is used to send and receive mail. The message contains two parts:
body and header. The body is the main part of the message while the header
includes information such as the sender and recipient address. The header
also includes descriptive information such as the subject of the message. In
this case, the message body is like a letter and header is like an envelope
that contains the recipient's address.
2. Submission of Mail: After composing an email, the mail client then submits
the completed e-mail to the SMTP server by using SMTP on TCP port 25.
3. Delivery of Mail: E-mail addresses contain two parts: username of the
recipient and domain name. For example, vivek@gmail.com, where "vivek" is
the username of the recipient and "gmail.com" is the domain name.
If the domain name of the recipient's email address is different from the
sender's domain name, then MSA will send the mail to the Mail Transfer
Agent (MTA). To relay the email, the MTA will find the target domain. It
checks the MX record from Domain Name System to obtain the target
domain. The MX record contains the domain name and IP address of the
recipient's domain. Once the record is located, MTA connects to the exchange
server to relay the message.
4. Receipt and Processing of Mail: Once the incoming message is received,
the exchange server delivers it to the incoming server (Mail Delivery Agent)
which stores the e-mail where it waits for the user to retrieve it.
5. Access and Retrieval of Mail: The stored email in MDA can be retrieved by
using MUA (Mail User Agent). MUA can be accessed by using login and
password.
The World Wide Web is the common system for navigating The internet is a public network of network with a
the internet. It is not the only system that can be used for maze of wired and wireless connections between
such access, but it is by far the most common one. separate groups of servers computers and
countless devices from around the world
The World Wide Web is distinguished from other systems Along with Internters, there also exist the
through its use of HTTP (Hypertext Transfer Protocol). It can Intranets, which is the same type of information
be safely said that the HTTP is the language of the World network but more privatized in order to control
Wide Web access.
The HTTP along with being the language of the World Wide The internet is governed by a set of rules and
Web also governs it by dealing with linking of files, regulations collectively known as Internet
documents and other resources Protocol (IP). The IP deals with data transmitted
through the internet.
The invention of the World Wide Web can be credited to Sir The first workable prototype of the Internet was
Tim Berners Lee. During his work at the European the ARPANET (Advanced Research Project Agency
Organization for Nuclear Research in 1989, he had Network) in the late 1960s. After its adoption on
developed the basic idea of the WWW to merge the January 1st 1983, researchers began to develop a
evolving technologies of computers, data networks and “network of networks” which evolved into the
hypertext into a powerful and easy to use global information modern form of the Internet
system.
Both the World Wide Web and the Internet are concepts covered under the Science and Technology Segment
of the UPSC IAS Exam. Aspirants can study this segment through the links given below
Introduction
With the rise in data all around the world, there has been an observable and increasing interest
surrounding the wave of the non-relational database, also known as ‘NoSQL‘. Businesses and
organizations are seeking new methods to manage the flood of data and are drawn toward the
alternate database management tools and systems that are different from the traditional
relational database systems. Here comes MongoDB into the picture.
MongoDB tutorial provides basic and advanced concepts of SQL. Our MongoDB
tutorial is designed for beginners and professionals.
Our MongoDB tutorial includes all topics of MongoDB database such as insert
documents, update documents, delete documents, query documents, projection,
sort() and limit() methods, create a collection, drop collection, etc. There are also
given MongoDB interview questions to help you better understand the MongoDB
database.
What is MongoDB
MongoDB is an open-source document database that provides high performance,
high availability, and automatic scaling.
MongoDB is available under General Public license for free, and it is also available
under Commercial license from the manufacturer.
MongoDB was designed to work with commodity servers. Now it is used by the
company of all sizes, across all industry.
History of MongoDB
The initial development of MongoDB began in 2007 when the company was building
a platform as a service similar to window azure.
Window azure is a cloud computing platform and infrastructure, created by Microsoft, to build,
deploy and manage applications and service through a global network.
The first ready production of MongoDB has been considered from version 1.4 which
was released in March 2010.
MongoDB2.4.9 was the latest and stable version which was released on January 10,
2014.
All the modern applications require big data, fast features development, flexible
deployment, and the older database systems not competent enough, so the
MongoDB was needed.
o Scalability
o Performance
o High Availability
o Scaling from single server deployments to large, complex multi-site
architectures.
o Key points of MongoDB
o Develop Faster
o Deploy Easier
o Scale Bigger
1. FirstName = "John",
2. Address = "Detroit",
3. Spouse = [{Name: "Angela"}].
4. FirstName ="John",
5. Address = "Wick"
Mongo DB falls into a class of databases that calls Document Oriented Databases.
There is also a broad category of database known as No SQL Databases.
Features of MongoDB
These are some important features of MongoDB:
In MongoDB, you can search by field, range query and it also supports regular
expression searches.
2. Indexing
3. Replication
A master can perform Reads and Writes and a Slave copies data from the master
and can only be used for reads or back up (not writes)
4. Duplication of data
MongoDB can run over multiple servers. The data is duplicated to keep the system
up and also keep its running condition in case of hardware failure.
5. Load balancing
10. Stores files of any size easily without complicating your stack.
Now a day many companies using MongoDB to create new types of applications,
improve performance and availability.
Prerequisite
Before learning MongoDB, you must have the basic knowledge of SQL and OOPs.
Audience
Our MongoDB tutorial is designed to help beginners and professionals.
Problem
We assure that you will not find any problem in this MongoDB tutorial. But if there is
any mistake, please post the problem in contact form.
The Architecture of MongoDB NoSQL Database
Database: In simple words, it can be called the physical container for data. Each of the
databases has its own set of files on the file system with multiple databases existing on a single
MongoDB server.
Collection: A group of database documents can be called a collection. The RDBMS equivalent
to a collection is a table. The entire collection exists within a single database. There are no
schemas when it comes to collections. Inside the collection, various documents can have varied
fields, but mostly the documents within a collection are meant for the same purpose or for
serving the same end goal.
Find out more about MongoDB in this comprehensive MongoDB Tutorial now!
Moreover, businesses are increasingly finding out that MongoDB is ticking all the right boxes
when it comes to meeting the business requirements. Here is how:
MongoDB provides the right mix of technology and data for competitive advantage.
It is most suited for mission-critical applications since it considerably reduces risks.
It increasingly accelerated the time to value (TTV) and lowered the total cost of
ownership.
It builds applications that are just not possible with traditional relational databases.
It may be look like a weird concept, if you are from traditional SQL background
where you need to create a database, table and insert values in the table manually.
Here, in MongoDB you don't need to create a database manually because MongoDB
will create it automatically when you save the value into the defined collection at
first time.
You also don't need to mention what you want to create, it will be automatically
created at the time you save the value into the defined collection.
Here one thing is very remarkable that you can create collection manually by "db.createCollection()" but
not the database.
Syntax:
1. use DATABASE_NAME
1. >use javatpointdb
Swithched to db javatpointdb
1. >db
javatpointdb
1. >show dbs
local 0.078GB
Here, your created database "javatpointdb" is not present in the list, insert at
least one document into it to display database:
1. >db.movie.insert({"name":"javatpoint"})
WriteResult({ "nInserted": 1})
1. >show dbs
javatpointdb 0.078GB
local 0.078GB
Collections
A collection is a grouping of MongoDB documents. Documents within a collection can have
different fields. A collection is the equivalent of a table in a relational database system. A
collection exists within a single database
Collections Screen
The Collections screen lists the existing collections and views in the selected database. Each
list item includes the name and other general information for the collection or view.
To access the Collections screen for a database, from the Databases screen either:
click to enlarge
Collection Information
The Collections screen displays the following information for each collection in the selected
database:
Collection name
NOTE
Compass bases the document count that appears on the Collections screen on cached
metadata using collStats. This count might differ from the actual document count in the
collection. For example, an unexpected shutdown can throw off the count. Use
the db.collection.countDocuments() method for the most accurate document count.
Collation properties for the collection. Hover over a Collation banner to view the
properties for that collection.
Create a Collection
In the Create Collection dialog, enter the name of the collection to create.
Compass also provides you with Advanced Collection Options. You can select from the
following:
Drop a Collection
1
From the Collections screen, click on the trash can for the collection to delete. A confirmation
dialog appears.
Collection Details
The Collection Detail screen shows detailed information for a collection, including the
documents the collection contains. To see collection details, either:
Manage Documents
Schema Analysis
Manage Indexes
NOTE
The following functionality is not available if you are connected to a Data Lake:
Schema Analysis
Manage Indexes
You can open multiple Collection Detail screens in separate tabs. To open a new tab to view
collection details:
Click the caret icon next to the database which contains the collection you wish to view.
Limitations
The Create Collection button is not available if you are connected to a Data Lake.
Tabbed View
You can open multiple Collection Detail screens in separate tabs. To open a new tab to view
collection details:
1
Click the caret icon next to the database which contains the collection you wish to view.
Character(s
Matches in searched string
)
\ Marks the next character as either a special character, a literal, a back reference, or an octal escape. For example, 'd' matches
character "d". ' \d' matches a digit character. The sequence '\\' matches "\" and "\(" matches "(".
^ Matches the position at the beginning of the searched string. For example ^CF matches any string starting 'CF'.
Character(s
Matches in searched string
)
$ Matches the position at the end of the searched string. For example EZ$ matches any string ending 'EZ'.
? Matches the preceding subexpression zero or one time. For example, "mast(er)?" matches "mast" or "master". Also, see below
for additional uses of '?'.
* Matches the preceding subexpression zero or more times. For example, zo* matches "z" and "zoo".
+ Matches the preceding subexpression one or more times. For example, 'zo+' matches "zo" and zoo", but not "z".
{n} Matches exactly n times, where n is a nonnegative integer. For example, 'o{2}' matches the two o's in "zoo", but not the o in
"zero".
{n,} Matches at least n times, where n is a nonnegative integer. For example, 'o{2,}' matches all the o's in "zooooom" but not the o
"zero".
{n,m} Matches at least n times and at most m times, where n and m are nonnegative integers ( n <= m). For example, 'o{2,4}' match
the first four o's in "zooooom", but not the o in "zero".
? When '?' immediately follows any of the qualifiers (*, +, ?, {n}, {n,}, {n,m}), the matching pattern is non-greedy. While the
default pattern matching is to match as much of the searched string as possible, a non-greedy pattern matches as little of the
searched string as possible. For example, 'o+?' matches a single o in "zooom", while 'o+' matches all the o's.
(pattern) Matches pattern as a subexpression and remembers the match. The remembered match can be used in a following back refere
(described below) or in the replacement string of a search and replace operation. To match the parentheses characters ( and ),
'\(' and '\)'.
x|y Matches either x or y. For example, 'MAST(ER|FILE)' matches either "MASTER" or "MASTFILE".
Character(s
Matches in searched string
)
[charlist] Matches any single character in charlist. For example, '[aeiou]' matches the e in "Relativity".
[^charlist] Matches any single character not in charlist. For example, '[^aeiou]' matches the R in "Relativity".
[a-z] Matches any single character in the specified character range. For example, '[a-z]' matches any lowercase alphabetic characte
the range "a" through "z", inclusive.
[^m-z] Matches any single character not in the specified character range. For example, '[^m-z]' matches any character except those in
range "m" through "z", inclusive.
\b Matches a word boundary (the position between a word and a space). For example, "le\b" matches the "le" of "file" in the
searched string "lengthy file name", not the "le" in "lengthy".
\B Matches a non-word boundary. For example, "le\B" matches the "le" of "lengthy" in the searched string "lengthy file name",
the "le" in "file".
\num Matches a back reference to a remembered match, where num is a positive integer. For example, '(.)\1' matches two consecuti
identical characters.
The Browser Object Model (BOM) is used to interact with the browser.
The default object of browser is window means you can call all the functions of
window by specifying window or directly. For example:
1. window.alert("hello javatpoint");
is same as:
1. alert("hello javatpoint");
You can use a lot of properties (other objects) defined underneath the window
object like document, history, screen, navigator, location, innerHeight, innerWidth,
Note: The document object represents an html document. It forms DOM (Document Object Model).
Visit the next page to learn about window object fully with example.
Window Object
1. Window Object
2. Properties of Window Object
3. Methods of Window Object
4. Example of Window Object
Window is the object of browser, it is not the object of javascript. The javascript
objects are string, array, date etc.
Note: if html document contains frame or iframe, browser creates additional window objects for each
frame.
Method Description
confirm() displays the confirm dialog box containing message with ok and
cancel button.
setTimeou performs action after specified time like calling function, evaluating
t() expressions etc.
1. <script type="text/javascript">
2. function msg(){
3. alert("Hello Alert Box");
4. }
5. </script>
6. <input type="button" value="click" onclick="msg()"/>
The JavaScript history object represents an array of URLs visited by the user. By
using this object, you can load previous, forward or any particular page.
1. window.history
Or,
1. history
The JavaScript navigator object is used for browser detection. It can be used to
get browser information such as appName, appCodeName, userAgent etc.
1. window.navigator
Or,
1. navigator
1. <script>
2. document.writeln("<br/>navigator.appCodeName: "+navigator.appCodeName);
3. document.writeln("<br/>navigator.appName: "+navigator.appName);
4. document.writeln("<br/>navigator.appVersion: "+navigator.appVersion);
5. document.writeln("<br/>navigator.cookieEnabled: "+navigator.cookieEnabled);
6. document.writeln("<br/>navigator.language: "+navigator.language);
7. document.writeln("<br/>navigator.userAgent: "+navigator.userAgent);
8. document.writeln("<br/>navigator.platform: "+navigator.platform);
9. document.writeln("<br/>navigator.onLine: "+navigator.onLine);
10.</script>
Test it Now
navigator.appCodeName: Mozilla
navigator.appName: Netscape
navigator.appVersion: 5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
navigator.cookieEnabled: true
navigator.language: en-US
navigator.userAgent: Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/37.0.2062.124 Safari/537.36
navigator.platform: Win32
navigator.onLine: true
The JavaScript screen object holds information of browser screen. It can be used
to display screen width, height, colorDepth, pixelDepth etc.
1. window.screen
Or,
1. screen
1. <script>
2. document.writeln("<br/>screen.width: "+screen.width);
3. document.writeln("<br/>screen.height: "+screen.height);
4. document.writeln("<br/>screen.availWidth: "+screen.availWidth);
5. document.writeln("<br/>screen.availHeight: "+screen.availHeight);
6. document.writeln("<br/>screen.colorDepth: "+screen.colorDepth);
7. document.writeln("<br/>screen.pixelDepth: "+screen.pixelDepth);
8. </script>
Test it Now
screen.width: 1366
screen.height: 768
screen.availWidth: 1366
screen.availHeight: 728
screen.colorDepth: 24
screen.pixelDepth: 24
1. window.document
Is same as
1. document
According to W3C - "The W3C Document Object Model (DOM) is a platform and
language-neutral interface that allows programs and scripts to dynamically access
and update the content, structure, and style of a document."
Method Description
getElementsByName() returns all the elements having the given name value.
getElementsByTagNam returns all the elements having the given tag name.
e()
getElementsByClassNa returns all the elements having the given class name.
me()
Here, document is the root element that represents the html document.
value is the property, that returns the value of the input text.
Let's see the simple example of document object that prints name with welcome
message.
1. <script type="text/javascript">
2. function printvalue(){
3. var name=document.form1.name.value;
4. alert("Welcome: "+name);
5. }
6. </script>
7.
8. <form name="form1">
9. Enter Name:<input type="text" name="name"/>
10.<input type="button" onclick="printvalue()" value="print name"/>
11.</form>
Points to remember
o The constructor keyword is used to declare a constructor method.
o The class can contain one constructor method only.
o JavaScript allows us to use parent class constructor through super keyword.
1. <script>
2. class Employee {
3. constructor() {
4. this.id=101;
5. this.name = "Martin Roy";
6. }
7. }
8. var emp = new Employee();
9. document.writeln(emp.id+" "+emp.name);
10.</script>
Test it Now
Output:
JavaScript Array
JavaScript array is an object that represents a collection of similar type of
elements.
1. By array literal
2. By creating instance of Array directly (using new keyword)
3. By using an Array constructor (using new keyword)
1. var arrayname=[value1,value2.....valueN];
As you can see, values are contained inside [ ] and separated by , (comma).
Let's see the simple example of creating and using array in JavaScript.
1. <script>
2. var emp=["Sonoo","Vimal","Ratan"];
3. for (i=0;i<emp.length;i++){
4. document.write(emp[i] + "<br/>");
5. }
6. </script>
Test it Now
Sonoo
Vimal
Ratan
1. <script>
2. var i;
3. var emp = new Array();
4. emp[0] = "Arun";
5. emp[1] = "Varun";
6. emp[2] = "John";
7.
8. for (i=0;i<emp.length;i++){
9. document.write(emp[i] + "<br>");
10.}
11.</script>
Test it Now
Arun
Varun
John
1. <script>
2. var emp=new Array("Jai","Vijay","Smith");
3. for (i=0;i<emp.length;i++){
4. document.write(emp[i] + "<br>");
5. }
6. </script>
Test it Now
Jai
Vijay
Smith
Methods Description
copywithin() It copies the part of the given array with its own elements
and returns the modified array.
filter() It returns the new array containing the elements that pass
the provided function conditions.
find() It returns the value of the first element in the given array
that satisfies the specified condition.
findIndex() It returns the index value of the first element in the given
array that satisfies the specified condition.
map() It calls the specified function for every array element and
returns the new array