Full Stack Development PDF
Full Stack Development PDF
DEPARTMENT OF
COMPUTER SCIENCE AND ENGINEERING
INDEX
COURSE OBJECTIVES:
1. To become knowledgeable about the most recent web development technologies.
2. Idea for creating two tier and three tier architectural web applications.
3. Design and Analyse real time web applications.
4. Constructing suitable client and server side applications.
5. To learn core concept of both front end and back end programming.
UNIT - I
Web Development Basics: Web development Basics - HTML & Web servers Shell - UNIX CLI
Version control - Git & Github HTML, CSS
UNIT - II
Frontend Development: Javascript basics OOPS Aspects of JavaScript Memory usage and Functions
in JS AJAX for data exchange with server jQuery Framework jQuery events, UI components etc.
JSON data format.
UNIT - III
REACT JS: Introduction to React React Router and Single Page Applications React Forms, Flow
Architecture and Introduction to Redux More Redux and Client-Server Communication
UNIT - IV
Java Web Development: JAVA PROGRAMMING BASICS, Model View Controller (MVC) Pattern
MVC Architecture using Spring RESTful API using Spring Framework Building an application
using Maven
UNIT - V
Databases & Deployment: Relational schemas and normalization Structured Query Language (SQL)
Data persistence using Spring JDBC Agile development principles and deploying application in
Cloud
TEXT BOOKS:
1. Web Design with HTML, CSS, JavaScript and JQuery Set Book by Jon Duckett
Professional JavaScript for Web Developers Book by Nicholas C. Zakas
2. Learning PHP, MySQL, JavaScript, CSS & HTML5: A Step-by-Step Guide to Creating
Dynamic Websites by Robin Nixon
3. Full Stack JavaScript: Learn Backbone.js, Node.js and MongoDB. Copyright © 2015 BY
AZAT MARDAN
REFERENCE BOOKS:
COURSE OUTCOMES:
1. Develop a fully functioning website and deploy on a web server.
2. Gain Knowledge about the front end and back end Tools
3. Find and use code packages based on their documentation to produce working results in a
project.
4. Create web pages that function using external data.
5. Implementation of web application employing efficient database access.
<body>
Document body related tags
</body>
</html>
We will study all the header and body tags in subsequent chapters, but for now
let's see what is document declaration tag.
<!DOCTYPE html>
There are many other declaration types which can be used in HTML document
depending on what version of HTML is being used. We will see more details on
this while discussing <!DOCTYPE...> tag along with other HTML tags.
Heading Tags
Any document starts with a heading. You can use different sizes for your headings. HTML
also has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>,
<h5>, and <h6>. While displaying any heading, browser adds one line before and one line
after that heading.
Example
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each paragraph
of text should go in between an opening <p> and a closing </p> tag as shown below in the
example:
Example
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
The <br /> tag has a space between the characters br and the forward slash. If you omit
this space, older browsers will have trouble rendering the line break, while if you miss the
forward slash character and just use <br> it is not valid in XHTML.
Example
<!DOCTYPE html>
<html>
<head>
<title>Line Break Example</title>
</head>
<body>
<p>Hello<br />
You delivered your assignment on time.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
Centering Content
You can use <center> tag to put any content in the center of the page or any table cell.
Example
<!DOCTYPE html>
<html>
<head>
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates
a line from the current position in the document to the right margin and breaks the line
accordingly.
For example, you may want to give a line between two paragraphs as in the given example
below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
Again <hr /> tag is an example of the empty element, where you do not need opening
and closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash. If you
omit this space, older browsers will have trouble rendering the horizontal line, while if you
miss the forward slash character and just use <hr> it is not valid in XHTML
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in the HTML
document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve the
formatting of the source document.
Example
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
alert (strText)
Try using the same code without keeping it inside <pre>...</pre> tags
Nonbreaking Spaces
Suppose you want to use the phrase "12 Angry Men." Here, you would not want a browser to
split the "12, Angry" and "Men" across two lines:
In cases, where you do not want the client browser to break text, you should use a
nonbreaking space entity instead of a normal space. For example, when coding the
"12 Angry Men" in a paragraph, you should use something similar to the following code:
Example
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
</head>
<body>
<p>An example of this technique appears in the movie "12 Angry Men."</p>
</body>
</html>
3. HTML – ELEMENTS
An HTML element is defined by a starting tag. If the element contains other content, it
ends with a closing tag, where the element name is preceded by a forward slash as shown
below with few tags:
<br />
HTML documents consists of a tree of these elements and they specify how HTML documents
should be built, and what kind of content should be placed in what part of an HTML document.
For example, <p> is starting tag of a paragraph and </p> is closing tag of the same
paragraph but <p>This is paragraph</p> is a paragraph element.
Example
<!DOCTYPE html>
<html>
<head>
4. HTML – ATTRIBUTES
We have seen few HTML tags and their usage like heading tags <h1>, <h2>, paragraph
tag <p> and other tags. We used them so far in their simplest form, but most of the HTML
tags can also have attributes, which are extra bits of information.
An attribute is used to define the characteristics of an HTML element and is placed inside
the element's opening tag. All attributes are made up of two parts: a name and a value:
The name is the property you want to set. For example, the paragraph <p> element in
the example carries an attribute whose name is align, which you can use to indicate
the alignment of paragraph on the page.
The value is what you want the value of the property to be set and always put
within quotations. The below example shows three possible values of align attribute:
left, center and right.
Attribute names and attribute values are case-insensitive. However, the World Wide Web
Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4
recommendation.
Example
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
Core Attributes
The four core attributes that can be used on the majority of HTML elements (although not all)
are:
Id
Title
Class
Style
The Id Attribute
The id attribute of an HTML tag can be used to uniquely identify any element within an
HTML page. There are two primary reasons that you might want to use an id attribute on an
element:
If you have two elements of the same name within a Web page (or style sheet), you
can use the id attribute to distinguish between elements that have the same name.
We will discuss style sheet in separate tutorial. For now, let's use the id attribute to
distinguish between two paragraph elements as shown below.
Example
<p id="html">This para explains what is HTML</p>
<p id="css">This para explains what is Cascading Style Sheet</p>
The behavior of this attribute will depend upon the element that carries it, although it is often
displayed as a tooltip when cursor comes over the element or while the element is loading.
Example
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h3 title="Hello HTML!">Titled Heading Tag Example</h3>
</body>
</html>
Now try to bring your cursor over "Titled Heading Tag Example" and you will see that
whatever title you used in your code is coming out as a tooltip of the cursor.
The value of the attribute may also be a space-separated list of class names. For example:
<!DOCTYPE html>
<html>
<head>
<title>The style Attribute</title>
</head>
<body>
<p style="font-family:arial; color:#FF0000;">Some text...</p>
</body>
</html>
Some text...
At this point of time, we are not learning CSS, so just let's proceed without bothering much
about CSS. Here, you need to understand what are HTML attributes and how they can be
used while formatting content.
Internationalization Attributes
There are three internationalization attributes, which are available for most (although not
all) XHTML elements.
dir
lang
xml:lang
Value Meaning
rtl Right to left (for languages such as Hebrew or Arabic that are read right to left)
Example
<!DOCTYPE html>
<html dir="rtl">
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-to-left directed text.
</body>
</html>
When dir attribute is used within the <html> tag, it determines how text will be presented
within the entire document. When used within another tag, it controls the text's direction for
just the content of that tag.
The lang Attribute
The lang attribute allows you to indicate the main language used in a document, but this
attribute was kept in HTML only for backwards compatibility with earlier versions of HTML.
This attribute has been replaced by the xml:lang attribute in new XHTML documents.
The values of the lang attribute are ISO-639 standard two-character language codes. Check
HTML Language Codes: ISO 639 for a complete list of language codes.
Example
<!DOCTYPE html>
<html lang="en">
<head>
<title>English Language Page</title>
</head>
<body>
This page is using English Language
</body>
</html>
Generic Attributes
Here's a table of some other attributes that are readily usable with many of the HTML tags.
Attribute Options Function
We will see related examples as we will proceed to study other HTML tags. For a complete
list of HTML Tags and related attributes please check reference to HTML Tags List.
If you use a word processor, you must be familiar with the ability to make text bold,
italicized, or underlined; these are just three of the ten options available to indicate how
text can appear in HTML and XHTML.
Bold Text
Anything that appears within <b>...</b> element, is displayed in bold as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
</body>
</html>
Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
<body>
<p>The following word uses a <i>italicized</i> typeface.</p>
</body>
</html>
Underlined Text
Anything that appears within <u>...</u> element, is displayed with underline as shown
below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Underlined Text Example</title>
</head>
<body>
<p>The following word uses a <u>underlined</u> typeface.</p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Strike Text Example</title>
</head>
<body>
<p>The following word uses a <strike>strikethrough</strike> typeface.</p>
</body>
</html>
This will produce the following result:
Monospaced Font
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts are
known as variable-width fonts because different letters are of different widths (for example,
the letter 'm' is wider than the letter 'i'). In a monospaced font, however, each letter has
the same width.
Example
<!DOCTYPE html>
<html>
<head>
<title>Monospaced Font Example</title>
</head>
<body>
<p>The following word uses a <tt>monospaced</tt> typeface.</p>
</body>
</html>
Superscript Text
The content of a <sup>...</sup> element is written in superscript; the font size used is
the same size as the characters surrounding it but is displayed half a character's height
above the other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup> typeface.</p>
</body>
</html>
superscript
The following word uses a typeface.
Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the
same as the characters surrounding it, but is displayed half a character's height beneath the
other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub> typeface.</p>
</body>
</html>
Inserted Text
Anything that appears within <ins>...</ins> element is displayed as inserted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
Page
Department of CSE MRCET
Page
Department of CSE MRCET
Deleted Text
Anything that appears within <del>...</del> element, is displayed as deleted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
Larger Text
The content of the <big>...</big> element is displayed one font size larger than the rest
of the text surrounding it as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big> typeface.</p>
</body>
</html>
Smaller Text
The content of the <small>...</small> element is displayed one font size smaller than
the rest of the text surrounding it as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small> typeface.</p>
</body>
</html>
Grouping Content
The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
For example, you might want to put all of the footnotes on a page within a <div> element
to indicate that all of the elements within that <div> element relate to the footnotes. You
might then attach a style to this <div> element so that they appear using a special set of
style rules.
Example
<!DOCTYPE html>
<html>
Page
Department of CSE MRCET
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id="menu" align="middle" >
<a href="/index.htm">HOME</a> |
<a href="/about/contact_us.htm">CONTACT</a> |
<a href="/about/index.htm">ABOUT</a> </div>
CONTENT ARTICLES
The <span> element, on the other hand, can be used to group inline elements only. So, if
you have a part of a sentence or paragraph which you want to group together, you could
use the <span> element as follows
Example
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span style="color:green">span tag</span> and the <span
style="color:red">div tag</span> alongwith CSS</p>
</body>
</html>
This is the example of span tag and the div tag along with CSS
These tags are commonly used with CSS to allow you to attach a style to a section of a page.
Emphasized Text
Anything that appears within <em>...</em> element is displayed as emphasized text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Emphasized Text Example</title>
</head>
<body>
<p>The following word uses a <em>emphasized</em> typeface.</p>
</body>
</html>
Marked Text
Anything that appears with-in <mark>...</mark> element, is displayed as marked with
yellow ink.
Example
<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>
</head>
<body>
<p>The following word has been <mark>marked</mark> with yellow</p>
</body>
</html>
This will produce the following result:
The following word has been marked with yellow
Strong Text
Anything that appears within <strong>...</strong> element is displayed as important text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Strong Text Example</title>
</head>
<body>
<p>The following word uses a <strong>strong</strong> typeface.</p>
</body>
</html>
Text Abbreviation
You can abbreviate a text by putting it inside opening <abbr> and closing </abbr> tags. If
present, the title attribute must contain this full description and nothing else.
Example
<!DOCTYPE html>
<html>
<head>
<title>Text Abbreviation</title>
</head>
<body>
<p>My best friend's name is <abbr title="Abhishek">Abhy</abbr>.</p>
</body>
</html>
Acronym Element
The <acronym> element allows you to indicate that the text between <acronym> and
</acronym> tags is an acronym.
At present, the major browsers do not change the appearance of the content of the
<acronym> element.
Example
<!DOCTYPE html>
<html>
<head>
<title>Acronym Example</title>
</head>
<body>
<p>This chapter covers marking up text in <acronym>XHTML</acronym>.</p>
</body>
</html>
Text Direction
The <bdo>...</bdo> element stands for Bi-Directional Override and it is used to override
the current text direction.
Example
<!DOCTYPE html>
<html>
<head>
<title>Text Direction Example</title>
</head>
<body>
<p>This text will go left to right.</p>
<p><bdo dir="rtl">This text will go right to left.</bdo></p>
</body>
</html>
Special Terms
The <dfn>...</dfn> element (or HTML Definition Element) allows you to specify that you are
introducing a special term. It's usage is similar to italic words in the midst of a paragraph.
Typically, you would use the <dfn> element the first time you introduce a key term. Most
recent browsers render the content of a <dfn> element in an italic font.
Example
<!DOCTYPE html>
<html>
<head>
<title>Special Terms Example</title>
</head>
<body>
<p>The following word is a <dfn>special</dfn> term.</p>
</body>
</html>
Quoting Text
When you want to quote a passage from another source, you should put it in
between<blockquote>...</blockquote> tags.
Text inside a <blockquote> element is usually indented from the left and right edges of the
surrounding text, and sometimes uses an italicized font.
Example
<!DOCTYPE html>
<html>
<head>
<title>Blockquote Example</title>
</head>
<body>
<p>The following description of XHTML is taken from the W3C Web site:</p>
The following description of XHTML is taken from the W3C Web site:
XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier
work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.
Short Quotations
The <q>...</q> element is used when you want to add a double quote within a sentence.
Example
<!DOCTYPE html>
<html>
<head>
Text Citations
If you are quoting a text, you can indicate the source placing it between an opening
<cite>tag and closing </cite> tag
As you would expect in a print publication, the content of the <cite> element is rendered in
italicized text by default.
Example
<!DOCTYPE html>
<html>
<head>
<title>Citations Example</title>
</head>
<body>
<p>This HTML tutorial is derived from <cite>W3 Standard for HTML</cite>.</p>
</body>
</html>
Computer Code
Any programming code to appear on a Web page should be placed inside
<code>...</code>tags. Usually the content of the <code> element is presented in a
monospaced font, just like the code in most programming books.
Example
<!DOCTYPE html>
<html>
<head>
<title>Computer Code Example</title>
</head>
<body>
<p>Regular text. <code>This is code.</code> Regular text.</p>
</body>
</html>
Keyboard Text
When you are talking about computers, if you want to tell a reader to enter some text, you
can use the <kbd>...</kbd> element to indicate what should be typed in, as in this
example.
Example
<!DOCTYPE html>
<html>
<head>
<title>Keyboard Text Example</title>
</head>
<body>
<p>Regular text. <kbd>This is inside kbd element</kbd> Regular text.</p>
</body>
</html>
Programming Variables
This element is usually used in conjunction with the <pre> and <code> elements to
indicate that the content of that element is a variable.
Example
<!DOCTYPE html>
<html>
<head>
<title>Variable Text Example</title>
</head>
<body>
<p><code>document.write("<var>user-name</var>")</code></p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Program Output Example</title>
</head>
<body>
<p>Result produced by the program is <samp>Hello World!</samp></p>
</body>
</html>
Address Text
The <address>...</address> element is used to contain any address.
Example
<!DOCTYPE html>
<html>
<head>
<title>Address Example</title>
</head>
<body>
<address>388A, Road No 22, Jubilee Hills - Hyderabad</address>
</body>
</html>
The <meta> tag is used to provide such additional information. This tag is an empty
element and so does not have a closing tag but it carries information within its attributes.
You can include one or more meta tags in your document based on what information you
want to keep in your document but in general, meta tags do not impact physical appearance
of the document so from appearance point of view, it does not matter if you include them or
not.
Attribute Description
Name Name for the property. Can be anything. Examples include, keywords,
description, author, revised, generator etc.
scheme Specifies a scheme to interpret the property's value (as declared in the
content attribute).
http- Used for http response message headers. For example, http-equiv can be
equiv used to refresh the page or to set a cookie. Values include content-type,
expires, refresh and set-cookie.
Specifying Keywords
You can use <meta> tag to specify important keywords related to the document and later
these keywords are used by the search engines while indexing your webpage for searching
purpose.
Example
Following is an example, where we are adding HTML, Meta Tags, Metadata as important
keywords about the document.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Hello HTML5!
Document Description
You can use <meta> tag to give a short description about the document. This again can be
used by various search engines while indexing your webpage for searching purpose.
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Document Refreshing
A <meta> tag can be used to specify a duration after which your web page will keep
refreshing automatically.
Example
If you want your page keep refreshing after every 5 seconds then use the following syntax.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
Page Redirection
You can use <meta> tag to redirect your page to any other webpage. You can also specify a
duration if you want to redirect the page after a certain number of seconds.
Example
Following is an example of redirecting current page to another page after 5 seconds. If you
want to redirect page immediately then do not specify content attribute.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<p>Hello HTML5!</p>
</body>
</html>
WEB SERVER
A web server is a computer that stores web server software and a website's component files (for
example, HTML documents, images, CSS stylesheets, and JavaScript files). A web server
connects to the Internet and supports physical data interchange with other devices connected to
the web.
A web server includes several parts that control how web users access hosted files. At a
minimum, this is an HTTP server. An HTTP server is software that understands URLs (web
addresses) and HTTP (the protocol your browser uses to view webpages). An HTTP server can
be accessed through the domain names of the websites it stores, and it delivers the content of
these hosted websites to the end user's device.
At the most basic level, whenever a browser needs a file that is hosted on a web server, the
browser requests the file via HTTP. When the request reaches the correct (hardware) web server,
the (software) HTTP server accepts the request, finds the requested document, and sends it back
to the browser, also through HTTP. (If the server doesn't find the requested document, it returns
a 404 response instead.)
A static web server, or stack, consists of a computer (hardware) with an HTTP server (software).
We call it "static" because the server sends its hosted files as-is to your browser.
A dynamic web server consists of a static web server plus extra software, most commonly an
application server and a database. We call it "dynamic" because the application server updates
the hosted files before sending content to your browser via the HTTP server.
For example, to produce the final webpages you see in the browser, the application server might
fill an HTML template with content from a database. Sites like MDN or Wikipedia have
thousands of webpages. Typically, these kinds of sites are composed of only a few HTML
templates and a giant database, rather than thousands of static HTML documents. This setup
makes it easier to maintain and deliver the content.
It is used for:
Github
GitHub is a code hosting platform for version control and collaboration. It
lets you and others work together on projects from anywhere.
This tutorial teaches you GitHub essentials like repositories, branches,
commits, and pull requests. You'll create your own Hello World repository
and learn GitHub's pull request workflow, a popular way to create and review
code.
In this quickstart guide, you will:
• Create and use a repository
• Start and manage a new branch
• Make changes to a file and push them to GitHub as commits
• Open and merge a pull request
To complete this tutorial, you need a GitHub account and Internet access.
You don't need to know how to code, use the command line, or install Git
(the version control software that GitHub is built on). If you have a question
about any of the expressions used in this guide, head on over to the
glossary to find out more about our terminology.
Creating a repository
A repository is usually used to organize a single project. Repositories can
contain folders and files, images, videos, spreadsheets, and data sets --
anything your project needs. Often, repositories include a README file, a file
with information about your project. README files are written in the plain
text Markdown language. You can use this cheat sheet to get started with
Markdown syntax. GitHub lets you add a README file at the same time you
create your new repository. GitHub also offers other common options such
as a license file, but you do not have to select any of them now.
Your hello-world repository can be a place where you store ideas, resources,
or even share and discuss things with others.
1. In the upper-right corner of any page, use the drop-down menu, and
select
2. New repository.
3. In the Repository name box, enter hello-world.
4. In the Description box, write a short description.
Creating a branch
Branching lets you have different versions of a repository at one time.
By default, your repository has one branch named main that is considered to
be the definitive branch. You can create additional branches off of main in
your repository. You can use branches to have different versions of a project
at one time. This is helpful when you want to add new features to a project
without changing the main source of code. The work done on different
branches will not show up on the main branch until you merge it, which we
will cover later in this guide. You can use branches to experiment and make
edits before committing them to main.
When you create a branch off the main branch, you're making a copy, or
snapshot, of main as it was at that point in time. If someone else made
changes to the main branch while you were working on your branch, you
could pull in those updates.
This diagram shows:
The main branch
A new branch called feature
The journey that feature takes before it's merged into main
story.txt
story-edit.txt
story-edit-reviewed.txt
Branches accomplish similar goals in GitHub repositories.
Here at GitHub, our developers, writers, and designers use branches for
keeping bug fixes and feature work separate from our main (production)
branch. When a change is ready, they merge their branch into main.
What is CSS?
While HTML is a markup language used to format/structure a web page,
CSS is a design language that you use to make your web page look nice
and presentable.
CSS stands for Cascading Style Sheets, and you use it to improve the
appearance of a web page. By adding thoughtful CSS styles, you make
your page more attractive and pleasant for the end user to view and use.
Imagine if human beings were just made to have skeletons and bare
bones – how would that look? Not nice if you ask me. So CSS is like our
skin, hair, and general physical appearance.
To access these elements, you have to “select” them. You can select a
single or multiple web elements and specify how you want them to look
or be positioned.
The rules that govern this process are called CSS selectors.
With CSS you can set the colour and background of your elements, as
well as the typeface, margins, spacing, padding and so much more.
If you remember our example HTML page, we had elements which were
pretty self-explanatory. For example, I stated that I would change the
color of the level one heading h1 to red.
To illustrate how CSS works, I will be sharing the code which sets the
background-color of the three levels of headers to red, blue, and green
respectively:
h1 {
background-color: #ff0000;
}
h2 {
background-color: #0000FF;
}
h3 {
background-color: #00FF00;
}
em {
background-color: #000000;
color: #ffffff;
}
localhost:3000/styles.css
The above style, when applied, will change the appearance of our web
page to this:
Cool, right?
When you sense danger, you run. When you are hungry, you eat. When
you are tired, you sleep. When you are cold, you look for warmth. When
crossing a busy road, you calculate the distance of vehicles away from
you.
You can access any elements through the Document Object Model API
(DOM) and make them change however you want them to.
The DOM is a tree-like representation of the web page that gets loaded
into the browser.
Eac
h element on the web page is represented on the DOM
Thanks to the DOM, we can use methods like getElementById() to access
elements from our web page.
JavaScript allows you to make your webpage “think and act”, which is
what programming is all about.
If you remember from our example HTML page, I mentioned that I was
going to sum up the two numbers displayed on the page and then
display the result in the place of the placeholder text. The calculation
runs once the button gets clicked.
Cli
cking the "Get the sum" button will display the sum of 2 and 7
This code illustrates how you can do calculations with JavaScript:
function displaySum() {
let firstNum = Number(document.getElementById('firstNum').innerHTML)
let secondNum = Number(document.getElementById('secondNum').innerHTML)
document.getElementById('sumButton').addEventListener("click", displaySum);
Remember what I told you about HTML attributes and their uses? This
code displays just that.
The displaySum is a function which gets both items from the web page,
converts them to numbers (with the Number method), sums them up,
and passes them in as inner values to another element.
So thanks to this:
2
plus 7 is equals to 9
If you want to get started with JavaScript, you can check out
freeCodeCamp's JavaScript Algorithms and Data Structures certification.
And you can use this great Intro to JS course to supplement your learning.
And when you link together some web pages with hyperlinks, along with
all their assets like images, videos, and so on that are on the server
computer, it gets rendered into a website.
This rendering typically happens on the front end, where the users can
see what's being displayed and interact with it.
Wrapping Up
As a web developer, the three main languages we use to build websites
are HTML, CSS, and JavaScript.
These days, CSS has become more than just a design language,
though. You can actually implement animations and smooth transitions
with just CSS.
In fact, you can do some basic programming with CSS too. An example
of this is when you use media queries, where you define different style
rules for different kinds of screens (resolutions).
JavaScript has also grown beyond being used just in the browser as
well. We now use it on the server thanks to Node.js.
But the basic fact remains: HTML, CSS, and JavaScript are the main
languages of the Web.
So that's it. The languages of the Web explained in basic terms. I really
hope you got something useful from this article.
Ruby, and Unix shell scripts are also used, although these languages are
less commonly used.[1][2][3]
Examples
Although uname available on all Unix variants, there are other ways to display
OS versions and names. Let us look at operating system-specific information.
system_profiler SPSoftwareDataType
HP-UX Unix
Use the swlist command as follows for determining your HP-UX Unix system
version:
swlist
swlist | grep -i oe
swlist HPUX*OE*
swlist HPUX*OE*
You will see something as follows:
HPUX11i-OE-Ent B.11.23.0606 HP-UX Enterprise Operating Environment
Component
OR
Summing up
The uname and other Unix command commands can help you determine
information about your Unix server or desktop, including its hardware type,
machine model, operating system version. The uname and other options
various. Hence, see the following man pages:
man uname
Working directory: This is your local directory where you make the
project (write code) and make changes to it.
Staging Area (or index): this is an area where you first need to put your
project before committing. This is used for code review by other team
members.
Local Repository: this is your local repository where you commit
changes to the project before pushing them to the central repository
on Github. This is what is provided by the distributed version control
system. This corresponds to the .git folder in our directory.
Central Repository: This is the main project on the central server, a
copy of which is with every team member as a local repository.
All the repository structure is internal to Git and is transparent to the
developer.
User share their repository online for various reasons including but not
limited to project deployment, project sharing, open source
contribution, helping out the community and many such.
By git remote add origin http_url: remote means the remote central
repository. Origin corresponds to your central repository which you
need to define (hereby giving HTTPS URL) in order to push changes to
Github.
Via SSH: connect to Linux or other servers remotely.
If you access Github by ssh you don’t need to type your username and
password every time you push changes to GitHub.
Terminal commands:
eval "$(ssh-agent -s)" -> enable information about local login session.
Now, go to github settings -> new ssh key -> create key
Initialize directory
git init
initializes your directory to work with git and makes a local repository.
.git folder is made (OR)
git stash
Whichever files are present in the staging area, it will move that files to
stash before committing it.
First, your file is in your working directory, Move it to the staging area
by typing:
In many cases, the project creates a lot of logs and other irrelevant files
which are to be ignored. So to ignore those files, we have to put their
names in“.gitignore” file.
touch .gitignore
echo "filename.ext" >>.gitignore
#to ignore all files with .log extension
echo "*.log" > .gitignore
Now the filenames written in the .gitignore file would be ignored while
pushing a new commit. To get the changes between commits, commit,
and working tree.
git diff
‘git diff’ command compares the staging area with the working
directory and tells us the changes made. It compares the earlier
information as well as the current modified information.
Branching in Git
Another way
You can contribute to any open source project on Github by forking it,
making desired changes to the forked repository, and then opening a
pull request. The project owner will review your project and will ask to
improve it or will merge it.
UNIT - II
Frontend Development: Javascript basics OOPS Aspects of
JavaScript Memory usage and Functions in JS AJAX for data
exchange with server jQuery Framework jQuery events, UI
components etc. JSON data format.
Let’s dive into the details of each one of them and see how they are
implemented in JavaScript.
Object: An Object is a unique entity that
contains properties and methods. For example “a car” is a real-life
Object, which has some characteristics like color, type, model, and
horsepower and performs certain actions like driving. The characteristics
//method
getFunction : function(){
return (`The name of the person is
${person.first_name} ${person.last_name}`)
},
//object within object
phone_number : {
mobile:'12345',
landline:'6789'
}
}
console.log(person.getFunction());
console.log(person.phone_number.landline);
Output:
E
xample: Using an Object Constructor.
Javascript
// Using a constructor
function person(first_name,last_name){
this.first_name = first_name;
this.last_name = last_name;
}
// Creating new instances of person object
let person1 = new person('Mukul','Latiyan');
let person2 = new person('Rahul','Avasthi');
console.log(person1.first_name);
console.log(`${person2.first_name} ${person2.last_name}`);
Output:
N
ote: The JavaScript Object.create() Method creates a new object, using
an existing object as the prototype of the newly created object.
Example:
Javascript
// Object.create() example a
// simple object with some properties
const coder = {
isStudying : false,
printIntroduction : function(){
console.log(`My name is ${this.name}. Am I
studying?: ${this.isStudying}.`)
}
}
// Object.create() method
const me = Object.create(coder);
me.printIntroduction();
Output:
}
}
// Making object with the help of the constructor
let bike1 = new Vehicle('Hayabusa', 'Suzuki', '1340cc');
let bike2 = new Vehicle('Ninja', 'Kawasaki', '998cc');
console.log(bike1.name); // Hayabusa
console.log(bike2.maker); // Kawasaki
console.log(bike1.getDetails());
Output:
Vehicle.prototype.getDetails = function(){
console.log('The name of the bike is '+ this.name);
}
console.log(bike1.name);
console.log(bike2.maker);
console.log(bike1.getDetails());
Output:
S
ometimes encapsulation refers to the hiding of data or data
Abstraction which means representing essential features hiding the
background detail. Most of the OOP languages provide access modifiers
to restrict the scope of a variable, but there are no such access modifiers
in JavaScript, there are certain ways by which we can restrict the scope of
variables within the Class/Object.
Example:
Javascript
// Abstraction example
function person(fname,lname){
let firstname = fname;
let lastname = lname;
this.getDetails_access = function(){
return (`First name is: ${firstname}, Last
name is: ${lastname}`);
}
}
let person1 = new person('Mukul','Latiyan');
console.log(person1.firstname);
console.log(person1.getDetails_noaccess);
console.log(person1.getDetails_access());
Student Object and use all the properties and methods of the person
Object as well as define certain properties and methods for the Student
Object.
N
ote: The Person and Student objects both have the same method (i.e
toString()), this is called Method Overriding. Method Overriding allows a
method in a child class to have the same name(polymorphism) and
method signature as that of a parent class.
In the above code, the super keyword is used to refer to the immediate
parent class’s instance variable.
Polymorphism: Polymorphism is one of the core concepts of object-oriented
programming languages. Polymorphism means the same function with
different signatures is called many times. In real life, for example, a boy at
the same time may be a student, a class monitor, etc. So a boy can
perform different operations at the same time. Polymorphism can be
achieved by method overriding and method overloading
Functions in JS AJAX
What is Ajax?
Ajax stands for Asynchronous Javascript And Xml. Ajax is just a means of
loading data from the server and selectively updating parts of a web page
without reloading the whole page.
Ajax has become so popular that you hardly find an application that
doesn't use Ajax to some extent. The example of some large-scale Ajax-
driven online applications are: Gmail, Google Maps, Google Docs,
YouTube, Facebook, Flickr, and so many other applications.
Note: Ajax is not a new technology, in fact, Ajax is not even really a
technology at all. Ajax is just a term to describe the process of exchanging
data from a web server asynchronously through JavaScript, without
refreshing the page.
Tip: Don't get confused by the term X (i.e. XML) in AJAX. It is only there
for historical reasons. Other data exchange format such as JSON, HTML,
or plain text can be used instead of XML.
All modern browsers (Chrome, Firefox, IE7+, Safari, Opera) support the
XMLHttpRequest object.
Ajax Illustration
In the following section we'll discuss each step involved in this process
one by one:
Before you perform Ajax communication between client and server, the
first thing you must do is to instantiate an XMLHttpRequest object, as
shown below:
Now, the next step in sending the request to the server is to instantiating
the newly-created request object using the open() method of the
XMLHttpRequest object.
The open() method typically accepts two parameters— the HTTP request
method to use, such as "GET", "POST", etc., and the URL to send the
request to, like this:
Tip: The file can be of any kind, like .txt or .xml, or server-side scripting
files, like .php or .asp, which can perform some actions on the server (e.g.
inserting or reading data from database) before sending the response
back to the client.
And finally send the request to the server using the send() method of the
XMLHttpRequest object.
Note: The send() method accepts an optional body parameter which allow
us to specify the request's body. This is primarily used for HTTP POST
requests, since the HTTP GET request doesn't have a request body, just
request headers.
The GET method is generally used to send small amount of data to the
server. Whereas, the POST method is used to send large amount of data,
such as form data.
See the chapter on HTTP GET vs. POST for a detailed comparison of
these two methods.
In the following section we'll take a closer look at how Ajax requests
actually works.
The following example will show you how to make an Ajax GET request in
JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
function displayFullName() {
request.open("GET", "greet.php?fname=John&lname=Clark");
request.onreadystatechange = function() {
document.getElementById("result").innerHTML =
this.responseText;
};
request.send();
</script>
</head>
<body>
<div id="result">
</div>
</body>
</html>
The status property returns the numerical HTTP status code of the
XMLHttpRequest's response. Some of the common HTTP status codes
are listed below:
404 — Not Found. The server can't find the requested page.
Please check out the HTTP status codes reference for a complete list of
response codes.
Here's the code from our "greet.php" file that simply creates the full name
of a person by joining their first name and last name and outputs a
greeting message.
ExampleDownload
<?php
$fname = htmlspecialchars($_GET["fname"]);
$lname = htmlspecialchars($_GET["lname"]);
} else {
?>
The POST method is mainly used to submit a form data to the web server.
The following example will show you how to submit form data to the server
using Ajax.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script>
function postComment() {
request.open("POST", "confirmation.php");
request.onreadystatechange = function() {
document.getElementById("result").innerHTML =
this.responseText;
};
request.send(formData);
</script>
</head>
<body>
<form id="myForm">
<label>Name:</label>
<br>
<label>Comment:</label>
<div><textarea name="comment"></textarea></div>
</form>
<div id="result">
</div>
</body>
</html>
If you are not using the FormData object to send form data, for example, if
you're sending the form data to the server in the query string format, i.e.
request.send(key1=value1&key2=value2) then you need to explicitly set
the request header using setRequestHeader() method, like this:
request.setRequestHeader("Content-type", "application/x-www-form-
urlencoded");
Here's the code of our "confirmation.php" file that simply outputs the
values submitted by the user.
ExampleDownload
<?php
if($_SERVER["REQUEST_METHOD"] == "POST") {
$name = htmlspecialchars(trim($_POST["name"]));
$comment = htmlspecialchars(trim($_POST["comment"]));
} else {
} else {
?>
What is JSON?
JSON stands for JavaScript Object Notation
JSON is a lightweight data-interchange format
JSON is plain text written in JavaScript object notation
JSON is used to send data between computers
JSON is language independent *
*
The JSON syntax is derived from JavaScript object notation, but the JSON
format is text only.
Code for reading and generating JSON exists in many programming languages.
Since the format is text only, JSON data can easily be sent between computers,
and used by any programming language.
JavaScript has a built in function for converting JSON strings into JavaScript
objects:
JSON.parse()
JavaScript also has a built in function for converting an object into a JSON
string:
JSON.stringify()
You can receive pure text from a server and use it as a JavaScript object.
You can work with data as JavaScript objects, with no complicated parsing and
translations.
Storing Data
When storing data, the data has to be a certain format, and regardless of where
you choose to store it, text is always one of the legal formats.
JSON Example
This example is a JSON string:
name
age
car
If you parse the JSON string with a JavaScript program, you can access the
data as an object:
UNIT - III
REACT JS: Introduction to React React Router and Single Page Applications React
Forms, Flow Architecture and Introduction to Redux More Redux and Client-
Server Communication
Introduction to ReactJS
React is a popular JavaScript library used for web development. React.js or ReactJS or React are different ways
to represent ReactJS. Today’s many large-scale companies (Netflix, Instagram, to name a few) also use React JS.
There are many advantages of using this framework over other frameworks, and It’s ranking under the top 10
programming languages for the last few years under various language ranking indices.
What is ReactJS?
React.js is a front-end JavaScript framework developed by Facebook. To build composable user interfaces
predictably and efficiently using declarative code, we use React. It’s an open-source and component-based
framework responsible for creating the application’s view layer.
● ReactJs follows the Model View Controller (MVC) architecture, and the view layer is accountable for
handling mobile and web apps.
● React is famous for building single-page applications and mobile apps.
Let’s take an example: Look at the Facebook page, which is entirely built on React, to understand how react
does works.
As the figure shows, ReactJS divides the UI into multiple components, making the code easier to debug. This
way, each function is assigned to a specific component, and it produces some HTML which is rendered as output
by the DOM.
ReactJS History:
Jordan Walke created React, who worked as a software engineer in Facebook has first released an early React
prototype called "FaxJS.”
In 2011, React was first deployed on Facebook's News Feed, and later in 2012 on Instagram.
As the figure shows, ReactJS divides the UI into multiple components, making the code easier to debug. This
way, each function is assigned to a specific component, and it produces some HTML which is rendered as output
by the DOM.
ReactJS History:
Jordan Walke created React, who worked as a software engineer in Facebook has first released an early React
prototype called "FaxJS.”
In 2011, React was first deployed on Facebook's News Feed, and later in 2012 on Instagram.
There are various reasons why you should choose ReactJS as a primary tool for website UI development. Here,
we highlight the most notable ones and explain why these specifics are so important:
● Fast - Feel quick and responsive through the Apps made in React can handle complex updates.
● Modular - Allow you to write many smaller, reusable files instead of writing large, dense files of code.
The modularity of React is an attractive solution for JavaScript's visibility issues.
● Scalable - React performs best in the case of large programs that display a lot of data changes.
● Flexible - React approaches differently by breaking them into components while building user
interfaces. This is incredibly important in large applications.
● Popular - ReactJS gives better performance than other JavaScript languages due to t’s implementation
of a virtual DOM.
● Easy to learn - Since it requires minimal understanding of HTML and JavaScript, the learning curve is
low.
● Server-side rendering and SEO friendly - ReactJS websites are famous for their server-side rendering
feature. It makes apps faster and much better for search engine ranking in comparison to products with
client-side rendering. React even produces more opportunities for website SEO and can occupy higher
positions on the search result’s page.
● Reusable UI components - React improves development and debugging processes.
● Community - The number of tools and extensions available for ReactJS developers is tremendous. Along
with impressive out-of-box functionalities, more opportunities emerge once you discover how giant the
React galaxy is. React has a vibrant community and is supported by Facebook. Hence, it’s a reliable tool
for website development.
ReactJS Features:
JSX is a preferable choice for many web developers. It isn't necessary to use JSX in React development, but
there is a massive difference between writing react.js documents in JSX and JavaScript. JSX is a syntax extension
to JavaScript. By using that, we can write HTML structures in the same file that contains JavaScript code.
React.js is designed so that it will only support data that is flowing downstream, in one direction. If the data has
to flow in another direction, you will need additional features.
React contains a set of immutable values passed to the component renderer as properties in HTML tags. The
components cannot modify any properties directly but support a call back function to do modifications.
React contains a lightweight representation of real DOM in the memory called Virtual DOM. Manipulating real
DOM is much slower compared to VDOM as nothing gets drawn on the screen. When any object’s state changes,
VDOM modifies only that object in real DOM instead of updating whole objects.
That makes things move fast, particularly compared with other front-end technologies that have to update each
object even if only a single object changes in the web application.
4. Extensions
React supports various extensions for application architecture. It supports server-side rendering, Flux, and
Redux extensively in web app development. React Native is a popular framework developed from React for
creating cross-compatible mobile apps.
5. Debugging
Testing React apps is easy due to large community support. Even Facebook provides a small browser extension
that makes React debugging easier and faster.
1. ReactJS Components
Components are the heart and soul of React. Components (like JavaScript functions) let you split the UI into
independent, reusable pieces and think about each piece in isolation.
Components are building blocks of any React application. Every component has its structures, APIs, and
methods.
In React, there are two types of components, namely stateless functional and stateful class.
● Functional Components - These components have no state of their own and contain only a render
method. They are simply Javascript functions that may or may not receive data as parameters.
Stateless functional components may derive data from other components as properties (props).
function WelcomeMessage(props) {
● Class Components - These components are more complex than functional components. They can
manage their state and to return JSX on the screen have a separate render method. You can pass data
from one class to other class components.
render() {
return (
);
2. React State
A state is a place from where the data comes. The state in a component can change over time, and whenever it
changes, the component re-renders.
A change in a state can happen as a response to system-generated events or user action, and these changes
define the component’s behavior and how it will render.
state = {
name: "World"
};
updateName() {
render() {
return(
<div>
{this.state.name}
</div>
The state object is initialized in the constructor, and it can store multiple properties.
To perform a merge between the new and the previous state, use the setState() function.
3. React Props
Both Props and State are plain JavaScript objects and hold data that influence the output of render. And they
are different in one way: State is managed within the component (like variable declaration within a function),
whereas props get passed to the component (like function parameters).
Props are immutable, and this is why the component of a container should describe the state that can be
changed and updated, while the child components should only send data from the state using properties.
4. React Keys
In React, Keys are useful when working with dynamically created components. Setting the key value will keep
your component uniquely identified after the change.
They help React in identifying the items which have changed, are removed, or added.
In summary, State, Props, keys, and components are the few fundamental React concepts that you need to be
familiar with before working on it.
React Router
Routing is a process in which a user is directed to different pages based on their action or
request. ReactJS Router is mainly used for developing Single Page Web Applications. React
Router is used to define multiple routes in the application. When a user types a specific URL into
the browser, and if this URL path matches any 'route' inside the router file, the user will be
redirected to that particular route.
React Router is a standard library system built on top of the React and used to create routing in
the React application using React Router Package. It provides the synchronous URL on the
browser with data that will be displayed on the web page. It maintains the standard structure and
behavior of the application and mainly used for developing single page web applications.
1. react-router: It provides the core routing components and functions for the React
Router applications.
2. react-router-native: It is used for mobile applications.
3. react-router-dom: It is used for web applications design.
It is not possible to install react-router directly in your application. To use react routing, first, you
need to install react-router-dom modules in your application. The below command is used to
install react router dom.
Example
Step-1: In our project, we will create two more components along with App.js, which is already
present.
About.js
render() {
return <h1>About</h1>
render() {
return <h1>About</h1>
Contact.js
render() {
return <h1>Contact</h1>
App.js
render() {
return (
<div>
<h1>Home</h1>
</div>
Step-2: For Routing, open the index.js file and import all the three component files in it. Here,
you need to import line: import { Route, Link, BrowserRouter as Router } from 'react-
router-dom' which helps us to implement the Routing. Now, our index.js file looks like below.
What is Route?
It is used to define and render component based on the specified path. It will accept components
and render to define what should be rendered.
Index.js
import './index.css';
const routing = (
<Router>
<div>
</div>
</Router>
ReactDOM.render(routing, document.getElementById('root'));
Step-3: Open command prompt, go to your project location, and then type npm start. You will
get the following screen.
Now, if you enter manually in the browser: localhost:3000/about, you will see About
component is rendered on the screen.
Step-4: In the above screen, you can see that Home component is still rendered. It is because the
home path is '/' and about path is '/about', so you can observe that slash is common in both paths
which render both components. To stop this behavior, you need to use the exact prop. It can be
seen in the below example.
Index.js
import './index.css';
const routing = (
<Router>
<div>
</div>
</Router>
ReactDOM.render(routing, document.getElementById('root'));
Output
This component is used to create links which allow to navigate on different URLs and render its
content without reloading the webpage.
Example
Index.js
import './index.css';
const routing = (
<Router>
<div>
<ul>
<li>
<Link to="/">Home</Link>
</li>
<li>
<Link to="/about">About</Link>
</li>
<li>
<Link to="/contact">Contact</Link>
</li>
</ul>
</div>
</Router>
ReactDOM.render(routing, document.getElementById('root'));
Output
After adding Link, you can see that the routes are rendered on the screen. Now, if you click on
the About, you will see URL is changing and About component is rendered.
Now, we need to add some styles to the Link. So that when we click on any particular link, it can
be easily identified which Link is active. To do this react router provides a new trick NavLink
instead of Link. Now, in the index.js file, replace Link from Navlink and add properties
activeStyle. The activeStyle properties mean when we click on the Link, it should have a
specific style so that we can differentiate which one is currently active.
import './index.css';
const routing = (
<Router>
<div>
<ul>
<li>
{color:'red'}
}>Home</NavLink>
</li>
<li>
{color:'green'}
}>About</NavLink>
</li>
<li>
{color:'magenta'}
}>Contact</NavLink>
</li>
</ul>
</div>
</Router>
ReactDOM.render(routing, document.getElementById('root'));
Output
When we execute the above program, we will get the following screen in which we can see that
Home link is of color Red and is the only currently active link.
Now, when we click on About link, its color shown green that is the currently active link.
<Link> vs <NavLink>
The Link component allows navigating the different routes on the websites, whereas NavLink
component is used to add styles to the active routes.
React Forms
Forms are an integral part of any modern web application. It allows the users to interact with the
application as well as gather information from the users. Forms can perform many tasks that
depend on the nature of your business requirements and logic such as authentication of the user,
adding user, searching, filtering, booking, ordering, etc. A form can contain text fields, buttons,
checkbox, radio button, etc.
Creating Form
React offers a stateful, reactive approach to build a form. The component rather than the DOM
usually handles the React form. In React, the form is usually implemented by using controlled
components.
1. Uncontrolled component
2. Controlled component
Uncontrolled component
The uncontrolled input is similar to the traditional HTML form inputs. The DOM itself handles
the form data. Here, the HTML elements maintain their own state that will be updated when the
input value changes. To write an uncontrolled component, you need to use a ref to get form
values from the DOM. In other words, there is no need to write an event handler for every state
update. You can use a ref to access the input field value of the form from the DOM.
Example
In this example, the code accepts a field username and company name in an uncontrolled
component.
27. }
28. export default App;
Output
When you execute the above code, you will see the following screen.
After filling the data in the field, you get the message that can be seen in the below screen.
Controlled Component
In HTML, form elements typically maintain their own state and update it according to the user
input. In the controlled component, the input form element is handled by the component rather
than the DOM. Here, the mutable state is kept in the state property and will be updated only with
setState() method.
Controlled components have functions that govern the data passing into them on every
onChange event, rather than grabbing the data only once, e.g., when you click a submit button.
This data is then saved to state and updated with setState() method. This makes component have
better control over the form elements and data.
A controlled component takes its current value through props and notifies the changes through
callbacks like an onChange event. A parent component "controls" this changes by handling the
callback and managing its own state and then passing the new values as props to the controlled
component. It is also called as a "dumb component."
Example
Output
When you execute the above code, you will see the following screen.
After filling the data in the field, you get the message that can be seen in the below screen.
React Redux
Redux is an open-source JavaScript library used to manage application state. React uses Redux
for building the user interface. It was first introduced by Dan Abramov and Andrew Clark in
2015.
React Redux is the official React binding for Redux. It allows React components to read data
from a Redux Store, and dispatch Actions to the Store to update data. Redux helps apps to scale
by providing a sensible way to manage state through a unidirectional data flow model. React
Redux is conceptually simple. It subscribes to the Redux store, checks to see if the data which
your component wants have changed, and re-renders your component.
Redux was inspired by Flux. Redux studied the Flux architecture and omitted unnecessary
complexity.
● React Redux is the official UI bindings for react Application. It is kept up-to-date with
any API changes to ensure that your React components behave as expected.
● It encourages good 'React' architecture.
● It implements many performance optimizations internally, which allows to components
re-render only when it actually needs.
Redux Architecture
STORE: A Store is a place where the entire state of your application lists. It manages the status
of the application and has a dispatch(action) function. It is like a brain responsible for all moving
parts in Redux.
ACTION: Action is sent or dispatched from the view which are payloads that can be read by
Reducers. It is a pure object created to store the information of the user's event. It includes
information such as type of action, time of occurrence, location of occurrence, its coordinates,
and which state it aims to change.
REDUCER: Reducer read the payloads from the actions and then updates the store via the state
accordingly. It is a pure function to return a new state from the initial state.
In this section, we will learn how to implements Redux in React application. Here, we provide a
simple example to connect Redux and React.
Step-1 Create a new react project using create-react-app command. I choose the project name:
"reactproject." Now, install Redux and React-Redux.
In this step, we need to create folders and files for actions, reducers, components, and containers.
After creating folders and files, our project looks like as below image.
Step-3 Actions
It uses 'type' property to inform about data that should be sent to the Store. In this folder, we will
create two files: index.js and index.spec.js. Here, we have created an action creator that returns
our action and sets an id for every created item.
Index.js
1. let nextTodoId = 0
2. export const addTodo = text => ({
3. type: 'ADD_TODO',
4. id: nextTodoId++,
5. text
6. })
7.
Index.spec.js
Step-4 Reducers
As we know, Actions only trigger changes in the app, and the Reducers specify those changes.
The Reducer is a function which takes two parameters 'Action' and 'State' to calculate and return
an updated State. It read the payloads from the 'Actions' and then updates the 'Store' via the State
accordingly.
In the given files, each Reducer managing its own part of the global State. The State parameter is
different for every Reducer and corresponds to the part of the 'State' it manages. When the app
becomes larger, we can split the Reducers into separate files and keep them completely
independent and managing different data domains.
Here, we are using 'combineReducers' helper function to add any new Reducers we might use in
the future.
index.js
4.
5. export default combineReducers({
6. todos,
7. visibilityFilter
8. })
Todos.js
Todos.spec.js
30. id: 0
31. }
32. ], {
33. type: 'ADD_TODO',
34. text: 'Use Redux',
35. id: 1
36. })
37. ).toEqual([
38. {
39. text: 'Run the tests',
40. completed: false,
41. id: 0
42. }, {
43. text: 'Use Redux',
44. completed: false,
45. id: 1
46. }
47. ])
48.
49. expect(
50. todos([
51. {
52. text: 'Run the tests',
53. completed: false,
54. id: 0
55. }, {
56. text: 'Use Redux',
57. completed: false,
58. id: 1
59. }
60. ], {
61. type: 'ADD_TODO',
62. text: 'Fix the tests',
63. id: 2
64. })
65. ).toEqual([
66. {
67. text: 'Run the tests',
68. completed: false,
69. id: 0
70. }, {
71. text: 'Use Redux',
72. completed: false,
73. id: 1
74. }, {
75. text: 'Fix the tests',
76. completed: false,
77. id: 2
78. }
79. ])
80. })
81.
82. it('should handle TOGGLE_TODO', () => {
83. expect(
84. todos([
85. {
86. text: 'Run the tests',
87. completed: false,
88. id: 1
89. }, {
VisibilityFilter.js
8. return state9.
}
10. }
11. export default visibilityFilter
Step-5 Components
It is a Presentational Component, which concerned with how things look such as markup, styles.
It receives data and invokes callbacks exclusively via props. It does not know where the data
comes from or how to change it. It only renders what is given to them.
App.js
Footer.js
Link.js
13. e.preventDefault()
14. onClick()
15. }}
16. >
17. {children}
18. </a>
19. )
20. }
21.
22. Link.propTypes = {
23. active: PropTypes.bool.isRequired,
24. children: PropTypes.node.isRequired,
25. onClick: PropTypes.func.isRequired
26. }
27.
28. export default Link
Todo.js
11. {text}
12. </li>
13. )
14.
15. Todo.propTypes = {
16. onClick: PropTypes.func.isRequired,
17. completed: PropTypes.bool.isRequired,
18. text: PropTypes.string.isRequired
19. }
20.
21. export default Todo
TodoList.js
Step-6 Containers
It is a Container Component which concerned with how things work such as data fetching,
updates State. It provides data and behavior to presentational components or other container
components. It uses Redux State to read data and dispatch Redux Action for updating data.
AddTodo.js
15. dispatch(addTodo(input.value))
16. input.value = ''
17. }}>
18. <input ref={node => input = node} />
19. <button type="submit">
20. Add Todo
21. </button>
22. </form>
23. </div>
24. )
25. }
26. export default connect()(AddTodo)
FilterLink.js
15. mapDispatchToProps
16. )(Link)
VisibleTodoList.js
25. })
26.
27. export default connect(
28. mapStateToProps,
29. mapDispatchToProps
30. )(TodoList)
Step-7 Store
All container components need access to the Redux Store to subscribe to it. For this, we need to
pass it(store) as a prop to every container component. However, it gets tedious. So we
recommend using special React Redux component called which make the store available to all
container components without passing it explicitly. It used once when you render the root
component.
index.js
Output
Client-Server Communication
Client and server applications communicate by sending individual
messages on an as-needed basis, rather than an ongoing stream of
communication.
● Body
● Headers
● Query strings
● HTTP version
● Headers
● Body
Now that we know what HTTP is and why it’s used, let’s talk about
the different methods we have available to us.
In our weather app, we could use PUT to update all weather data
about a specific city.
In our weather app, we could use PATCH to update the rainfall for a
specified day in a specified city.
UNIT - IV
Java Web Development: JAVA PROGRAMMING BASICS, Model View Controller (MVC) Pattern
MVC Architecture using Spring RESTful API using Spring Framework Building an application using
Maven
application (input logic, business logic, and UI logic), while providing a loose coupling
between these elements.
The Model encapsulates the application data and in general they will consist of
POJO.
The View is responsible for rendering the model data and in general it generates
HTML output that the client's browser can interpret.
The Controller is responsible for processing user requests and building an
appropriate model and passes it to the view for rendering.
The DispatcherServlet
The Spring Web model-view-controller (MVC) framework is designed around
a DispatcherServlet that handles all the HTTP requests and responses. The request
processing workflow of the Spring Web MVC DispatcherServlet is illustrated in the
following diagram −
Once view is finalized, The DispatcherServlet passes the model data to the view
which is finally rendered on the browser.
All the above-mentioned components, i.e. HandlerMapping, Controller, and
ViewResolver are parts of WebApplicationContext which is an extension of the
plainApplicationContext with some extra features necessary for web applications.
Required Configuration
You need to map requests that you want the DispatcherServlet to handle, by using a
URL mapping in the web.xml file. The following is an example to show declaration and
mapping for HelloWeb DispatcherServlet example −
<web-app id = "WebApp_ID" version = "2.4"
xmlns = "http://java.sun.com/xml/ns/j2ee"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>HelloWeb</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>HelloWeb</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
</web-app>
The web.xml file will be kept in the WebContent/WEB-INF directory of your web
application. Upon initialization of HelloWeb DispatcherServlet, the framework will try to
load the application context from a file named [servlet-name]-servlet.xml located in
the application's WebContent/WEB-INF directory. In this case, our file will
be HelloWebservlet.xml.
Next, <servlet-mapping> tag indicates what URLs will be handled by which
DispatcherServlet. Here all the HTTP requests ending with .jsp will be handled by
the HelloWeb DispatcherServlet.
If you do not want to go with default filename as [servlet-name]-servlet.xml and default
location as WebContent/WEB-INF, you can customize this file name and location by
adding the servlet listener ContextLoaderListener in your web.xml file as follows −
<web-app...>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
</web-app>
Now, let us check the required configuration for HelloWeb-servlet.xml file, placed in
your web application's WebContent/WEB-INF directory −
<beans xmlns = "http://www.springframework.org/schema/beans"
xmlns:context = "http://www.springframework.org/schema/context"
xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation = "http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
</beans>
Following are the important points about HelloWeb-servlet.xml file −
The [servlet-name]-servlet.xml file will be used to create the beans defined,
overriding the definitions of any beans defined with the same name in the global
scope.
The <context:component-scan...> tag will be use to activate Spring MVC
annotation scanning capability which allows to make use of annotations like
@Controller and @RequestMapping etc.
The InternalResourceViewResolver will have rules defined to resolve the view
names. As per the above defined rule, a logical view named hello is delegated to
a view implementation located at /WEB-INF/jsp/hello.jsp .
The following section will show you how to create your actual components, i.e.,
Controller, Model, and View.
Defining a Controller
The DispatcherServlet delegates the request to the controllers to execute the
functionality specific to it. The @Controller annotation indicates that a particular class
serves the role of a controller. The @RequestMapping annotation is used to map a
URL to either an entire class or a particular handler method.
@Controller
@RequestMapping("/hello")
public class HelloController {
@RequestMapping(method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
The @Controller annotation defines the class as a Spring MVC controller. Here, the
first usage of @RequestMapping indicates that all handling methods on this controller
are relative to the /hello path.
Next annotation @RequestMapping(method = RequestMethod.GET) is used to
declare the printHello() method as the controller's default service method to handle
HTTP GET request. You can define another method to handle any POST request at the
same URL.
You can write the above controller in another form where you can add additional
attributes in @RequestMapping as follows −
@Controller
public class HelloController {
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String printHello(ModelMap model) {
model.addAttribute("message", "Hello Spring MVC Framework!");
return "hello";
}
}
The value attribute indicates the URL to which the handler method is mapped and
the method attribute defines the service method to handle HTTP GET request. The
following important points are to be noted about the controller defined above −
You will define required business logic inside a service method. You can call
another method inside this method as per requirement.
Based on the business logic defined, you will create a model within this method.
You can use setter different model attributes and these attributes will be
accessed by the view to present the final result. This example creates a model
with its attribute "message".
A defined service method can return a String, which contains the name of
the view to be used to render the model. This example returns "hello" as logical
view name.
<body>
<h2>${message}</h2>
</body>
</html>
Here ${message} is the attribute which we have set up inside the Controller. You can
have multiple attributes to be displayed inside your view.
https://www.tutorialspoint.com/spring/spring_web_mvc_framework.htm
RESTful API using Spring Framework
Web-based application development is a common part
of Java development. It is part and parcel of the
enterprise domain wherein they share many common attributes
of building a production-ready application. Spring uniquely
addresses the concern for building a Web application
through its MVC framework. It is called MVC because it is
based upon the MVC (Model-View-Controller) pattern. Refer
to Wikipedia: Model-view-controller for quick information
about this. Web applications, in most cases, have a REST
counterpart for resource sharing. This article builds up on
both the idea and ends with a quick example to describe
them in a terse manner.
Spring MVC
A Web application is inherently multi-layered because the
intricacies between the user request and server response go
through several in-between stages of information
processing. Each stage is handled by a layer. For example,
the Web interaction begins with user interaction with the
browser, such as by triggering a request and getting a
response from the server. The request response paradigm is
nothing more than an exchange of certain arranged data,
which can be anywhere from trivial to heavily loaded
information gathered from, for example, a form submitted by
the user. The URL encapsulates the request from the user
and flutters into the network oblivion. Voilà! It is
REST
REST is the acronym of Representational State Transfer. It
is a term coined in Roy Thomas Fielding’s doctoral
thesis where REST is a part that encompasses the
architecture of transferring the state of resources. The
REST architecture is made popular as an alternative to a
SOAP implementation of Web services. Although REST has a
much wider connotation than just Web services, here we’ll
limit our discussion to dealing with REST resources only.
The idea Web services are basically resource sharing in the
REST in Spring
The REST API support was introduced in Spring from version
3.0 onwards; since then, it has steadily evolved to the
present day. We can create REST resources in the following
ways:
CrudRepository<Employee, String>{
// ...
Employee.java
package
com.mano.spring_mvc_rest_example.spring_mvc_rest.employee;
public Employee() {
this.id = id;
this.name = name;
this.address = address;
return id;
this.id = id;
return name;
this.name = name;
return address;
this.address = address;
EmployeeService.java
package com.mano.spring_mvc_rest_example.spring_
mvc_rest.employee;
import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List;
@Service
"New York"),
"Gotham City"),
"Metropolis"),
new Employee("blackpanther","T'Challa",
"Wakanda"),
"New York")
);
return employeeList;
return employeeList.stream().filter(e->e.getId()
.equals(id)).findFirst().get();
for(int i=0;i<employeeList.size();i++){
Employee e=employeeList.get(i);
if(e.getId().equals(id)) {
employeeList.set(i, employee);
break;
employeeList.removeIf(e->e.getId().equals(id));
EmployeeController.java
package
com.mano.spring_mvc_rest_example.spring_mvc_rest.employee;
import
org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@Autowired
@RequestMapping("/employees")
return employeeService.getEmployees();
@RequestMapping("/employees/{empid}")
String id){
return employeeService.getEmployee(id);
@RequestMapping(method= RequestMethod.POST,
value="/employees")
employeeService.addEmployee(employee);
@RequestMapping(method = RequestMethod.PUT,
value="/employees/{id}")
employeeService.updateEmployee(employee, id);
@RequestMapping(method = RequestMethod.DELETE,
value="/employees/{id}")
employeeService>.deleteEmployee(id);
}
Observe that the Web controller class named
EmployeeController is designated as
a @RestController annotation. This is a convenience
annotation that actually combines
the @Controller and @ResponseBody annotations.
The @Controller annotation designates a POJO as a Web
controller and is a specialization of @Component. When we
designate a POJO class with @Controller or @Component, or
even a @RestController, Spring auto detects them by
considering them as a candidate while class path scanning.
The @ResponseBody annotation indicates that the method
response value should be bound to the Web response body.
Get one
employee: http://localhost:8080/employees/batman
Conclusion
For REST CRUD operations such as adding, updating, and
deleting Employee, we need a HTTP client application that
enables us to test Web services, such as postman;
otherwise, we need to implement the view layer of the
application with the help of JavaScript frameworks such
as jQuery, AngularJS, and the like. To keep the write-up
well within limits, we have not implemented them here. If
possible, we’ll take them up in a separate write-up. By the
way, we have only scratched the surface of Spring MVC and
Spring REST support. Take this as a warm-up before the deep
plunge you may want to take into the stream of Spring. As
you swim across, you’ll find many interesting sight scenes.
🙂
https://www.developer.com/java/exploring-rest-apis-with-
spring-mvc/
Lifecycle Management
One of the primary objectives of Maven is to manage the lifecycle of a Java
project. While building a Java application may appear to be a simple, one-
step process, there are actually multiple steps that take place. Maven
divides this process into three lifecycles:
Phases
1. validate
2. compile
3. test
4. package
5. deploy
Maven breaks phases down one more time into goals, which represent
discrete tasks that are executed as part of each phase. For example, when
we execute the compile phase in a Maven build, we are actually compiling
both the main sources that make up our project as well as the test sources
that will be used when executing our automated test cases.
Thus, the compile phase is composed of two goals:
1. compiler:compile
2. compiler:testCompile
The compiler portion of the goal is the plugin name. A Maven plugin is an
artifact that supplies Maven goals. The addition of these plugins allows
Maven to be extended beyond its basic functionality.
For example, suppose that we wish to add a goal that verifies that our code
meets the formatting standard of our company. To do this, we could create
a new plugin that has a goal that checks the source code and compares it to
our company standard, succeeding if our code meets the standard and
failing otherwise.
We can then tie this goal into the validate phase so that when Maven runs
the validate phase (such as when the compile phase is run), our custom
goal is executed. Creating such a plugin is outside the scope of this article,
but detailed information can be found in the official Maven Plugin
Development documentation.
Note that a goal may be associated with zero or more phases. If no phase is
associated with the goal, the goal will not be included in a build by default
but can be explicitly executed. For example, if we create a goal foo:bar that
is not associated with any phase, Maven will not execute this goal for us
(since no dependency is created to a phase that Maven is executing), but we
can explicitly instruct Maven to execute this goal on the command line:
1
mvn foo:bar
Likewise, a phase can have zero or more goals associated with it. If a phase
does not have any goals associated with it, though, it will not be executed
by Maven.
For a complete list of all phases and goals included in Maven by default, see
the official Maven Introduction to the Build Lifecycle documentation.
https://dzone.com/articles/building-java-applications-with-maven
UNIT - V
Databases & Deployment: Relational schemas and normalization Structured Query Language (SQL)
Data persistence using Spring JDBC Agile development principles and deploying application in Cloud
Relation Schema
Relation schema defines the design and structure of the relation like it consists
of the relation name, set of attributes/field names/column names. every attribute
would have an associated domain.
There is a student named Geeks, she is pursuing B.Tech, in the 4th year, and
belongs to IT department (department no. 1) and has roll number 1601347 She
is proctored by Mrs. S Mohanty. If we want to represent this using databases
we would have to create a student table with name, sex, degree, year,
department, department number, roll number and proctor (adviser) as the
attributes.
Teaching can be another table, having employee id, course id, semester, year
and classroom as attributes.
teaching (empId, coursed, sem, year, Classroom)
When we start courses, there are some courses which another course that
needs to be completed before starting the current course, so this can be
represented by the Prerequisite table having prerequisite course and course id
attributes.
10. This represents that the deptNo in student table is same as deptId
used in department table.
TABLE 1
These are some important terminologies that are used in terms of relation.
Attribute: Attributes are the properties that define a relation.
e.g.; ROLL_NO, NAME etc.
Tuple: Each row in the relation is known as tuple. The above relation contains 4
tuples, one of which is shown as:
1 RAM DELHI 9455123451 18
ROLL_NO
1 RAM
2 RAMESH
3 SUJIT
4 SURESH
ROLL_NO NAME
3 SUJIT
4 SURESH
ADDRESS
DELHI
GURGAON
ROHTAK
If DISTINCT is not used, DELHI will be repeated twice in result set. Before
understanding GROUP BY and HAVING, we need to understand aggregations
functions in SQL.
AGGRATION FUNCTIONS: Aggregation functions are used to perform
mathematical operations on data values of a relation. Some of the common
aggregation functions used in SQL are:
5. COUNT: Count function is used to count the number of rows in a
relation. e.g;
SELECT COUNT (PHONE) FROM STUDENT;
COUNT(PHONE)
74
In the same way, MIN, MAX and AVG can be used. As we have seen above,
all aggregation functions return only 1 row.
AVERAGE: It gives the average values of the tupples. It is also defined as sum
divided by count values.
Syntax:AVG(attributename)
OR
Syntax: SUM(attributename)/COUNT(attributename)
The above mentioned syntax also retrieves the average value of tupples.
MAXIMUM: It extracts the maximum value among the set of tupples.
Syntax:MAX(attributename)
MINIMUM: It extracts the minimum value amongst the set of all the tupples.
Syntax:MIN(attributename)
GROUP BY: Group by is used to group the tuples of a relation based on an
attribute or group of attribute. It is always combined with aggregation function
which is computed on group. e.g.;
SELECT ADDRESS, SUM(AGE) FROM STUDENT
GROUP BY (ADDRESS);
In this query, SUM(AGE) will be computed but not for entire table but for each
address. i.e.; sum of AGE for address DELHI(18+18=36) and similarly for other
address as well. The output is:
ADDRESS SUM(AGE)
DELHI 36
GURGAON 18
ROHTAK 20
If we try to execute the query given below, it will result in error because
although we have computed SUM(AGE) for each address, there are more than
1 ROLL_NO for each address we have grouped. So it can’t be displayed in
result set. We need to use aggregate functions on columns after SELECT
statement to make sense of the resulting set whenever we are using GROUP
BY.
SELECT ROLL_NO, ADDRESS, SUM(AGE) FROM STUDENT
GROUP BY (ADDRESS);
There are a number of options for selecting an approach to form the basis for
your JDBC database access. Spring framework provides the following
approaches for JDBC database access:
JdbcTemplate
NamedParameterJdbcTemplate
SimpleJdbcTemplate
SimpleJdbcInsert and SimpleJdbcCall
JDBC Template
JdbcTemplate is a central class in the JDBC core package that simplifies the
use of JDBC and helps to avoid common errors. It internally uses JDBC
API and eliminates a lot of problems with JDBC API. It executes SQL queries
or updates, initiating iteration over ResultSets and catching JDBC exceptions
and translating them to the generic. It executes core JDBC workflow, leaving
application code to provide SQL and extract results. It handles the exception
and provides the informative exception messages with the help of exception
classes defined in the org.springframework.dao package.
The common methods of spring JdbcTemplate class.
Methods Description
public int update(String query) Used to insert, update and delete records.
public int update(String query, Used to insert, update and delete records
Object… args) using PreparedStatement using given arguments.
Java
@Configuration
@ComponentScan("com.exploit.jdbc")
DriverManagerDataSource dataSource
= new DriverManagerDataSource();
dataSource.setDriverClassName(
"com.mysql.jdbc.Driver");
dataSource.setUrl(
"jdbc:mysql://localhost:8800/springjdbc");
dataSource.setUsername("user");
dataSource.setPassword("password");
return dataSource;
A. File: Student.java
Java
package com.exploit.org;
// Class
// Constructor
public Student() {}
B. File: StudentDAO.java
Below is the implementation of the Data Access Object interface file
StudentDAO.java.
Example:
Java
package com.exploit.org;
import java.util.List;
import javax.sql.DataSource;
// Class
// ie. connection
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
D. File: StudentJDBCTemplate.java
Below is the implementation class file StudentJDBCTemplate.java for the
defined DAO interface StudentDAO.
Example:
Java
// of StudentDAO Class
package com.exploit.org;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
// Class
// Method 1
this.dataSource = dataSource;
this.jdbcTemplateObject
= new JdbcTemplate(dataSource);
// Method 2
return students;
Deployment Models
The cloud deployment model identifies the specific type of cloud environment
based on ownership, scale, and access, as well as the cloud’s nature and
purpose. The location of the servers you’re utilizing and who controls them are
defined by a cloud deployment model. It specifies how your cloud infrastructure
will look, what you can change, and whether you will be given services or will
have to create everything yourself. Relationships between the infrastructure and
your users are also defined by cloud deployment types.
Public Cloud
The public cloud makes it possible for anybody to access systems and services.
The public cloud may be less secure as it is open to everyone. The public cloud
is one in which cloud infrastructure services are provided over the internet to
the general people or major industry groups. The infrastructure in this cloud
model is owned by the entity that delivers the cloud services, not by the
consumer. It is a type of cloud hosting that allows customers and users to easily
access systems and services. This form of cloud computing is an excellent
example of cloud hosting, in which service providers supply services to a variety
of customers. In this arrangement, storage backup and retrieval services are
given for free, as a subscription, or on a per-user basis. Example: Google App
Engine etc.
Private Cloud
The private cloud deployment model is the exact opposite of the public cloud
deployment model. It’s a one-on-one environment for a single user (customer).
There is no need to share your hardware with anyone else. The distinction
between private and public clouds is in how you handle all of the hardware. It is
also called the “internal cloud” & it refers to the ability to access systems and
services within a given border or organization. The cloud platform is
implemented in a cloud-based secure environment that is protected by powerful
firewalls and under the supervision of an organization’s IT department. The
private cloud gives greater flexibility of control over cloud resources.
Data Security and Privacy: It’s suitable for storing corporate information
to which only authorized staff have access. By segmenting resources within
the same infrastructure, improved access and security can be achieved.
Less scalable: Private clouds are scaled within a certain range as there
is less number of clients.
Hybrid Cloud
By bridging the public and private worlds with a layer of proprietary software,
hybrid cloud computing gives the best of both worlds. With a hybrid solution,
you may host the app in a safe environment while taking advantage of the
public cloud’s cost savings. Organizations can move data and applications
between different clouds using a combination of two or more cloud deployment
methods, depending on their needs.
Advantages of Hybrid Cloud Model:
.
Disadvantages of Hybrid Cloud Model:
Community Cloud
Multi-cloud
We’re talking about employing multiple cloud providers at the same time under
this paradigm, as the name implies. It’s similar to the hybrid cloud deployment
approach, which combines public and private cloud resources. Instead of
merging private and public clouds, multi-cloud uses many public
clouds. Although public cloud providers provide numerous tools to improve the
reliability of their services, mishaps still occur. It’s quite rare that two distinct
clouds would have an incident at the same moment. As a result, multi-cloud
deployment improves the high availability of your services even more.
Advantages of a Multi-Cloud Model:
You can mix and match the best features of each cloud provider’s
services to suit the demands of your apps, workloads, and business by
choosing different cloud providers.
High availability of service: It’s quite rare that two distinct clouds would
have an incident at the same moment. So, the multi-cloud deployment
improves the high availability of your services.
Disadvantages of Multi-Cloud Model:
services nowadays as they are getting a list of benefits from cloud computing.
Different organizations using cloud computing for different purposes and with
respect to that Cloud Service Providers are providing various applications in
different fields. Applications of Cloud Computing in real-world : Cloud
Service Providers (CSP) are providing many types of cloud services and now if
we will cloud computing has touched every sector by providing various cloud
applications. Sharing and managing resources is easy in cloud computing that’s
why it is one of the dominant fields of computing. These properties have made it
an active component in many fields. Now let’s know some of the real-world
applications of cloud computing.
1. Online Data Storage: Cloud computing allows storing data like files,
images, audios, and videos, etc on the cloud storage. The organization need
not set physical storage systems to store a huge volume of business data
which costs so high nowadays. As they are growing technologically, data
generation is also growing with respect to time, and storing that becoming
problem. In that situation, Cloud storage is providing this service to store and
access data any time as per requirement.
2. Backup and Recovery : Cloud vendors provide security from their side by
storing safe to the data as well as providing a backup facility to the data. They
offer various recovery application for retrieving the lost data. In the traditional
way backup of data is a very complex problem and also it is very difficult
sometimes impossible to recover the lost data. But cloud computing has made
backup and recovery applications very easy where there is no fear of running
out of backup media or loss of data.
3. Bigdata Analysis : We know the volume of big data is so high where storing
that in traditional data management system for an organization is impossible.
But cloud computing has resolved that problem by allowing the organizations
to store their large volume of data in cloud storage without worrying about
physical storage. Next comes analyzing the raw data and finding out insights
or useful information from it is a big challenge as it requires high-quality tools
for data analytics. Cloud computing provides the biggest facility to
organizations in terms of storing and analyzing big data.
4. Testing and development : Setting up the platform for development and
finally performing different types of testing to check the readiness of the
product before delivery requires different types of IT resources and
infrastructure. But Cloud computing provides the easiest approach for
development as well as testing even if deployment by using their IT
resources with minimal expenses. Organizations find it more helpful as they
got scalable and flexible cloud services for product development, testing,
and deployment.
5. Anti-Virus Applications : Previously, organizations were installing antivirus
software within their system even if we will see we personally also keep
antivirus software in our system for safety from outside cyber threats.