IP Sem 5 Imp
IP Sem 5 Imp
Class Id
We can apply a class to various elements The Id is unique in a page, and we can only
so that it could be numerous times on a apply it to one specific element.
single page.
The class is assigned to an element and its The name of the Id starts with the "#" symbol
name starts with "." followed by the name followed by a unique id name.
of the class.
We can attach multiple class selectors to We can attach only one ID selector to an
an element. element.
Syntax: Syntax:
.class{ #id{
// declarations of CSS // declarations of CSS
} }
1) Explain <Canvas> element in HTML5
The <canvas> tag in HTML is used to draw graphics on a web page using JavaScript. It can be
used to draw paths, boxes, texts, gradients, and adding images. By default, it does not
contain borders and text.
➢ <!DOCTYPE html>
➢ <html>
➢ <body>
➢ <!-- canvas Tag starts here -->
➢ <canvas id = "GeeksforGeeks" width = "200"
➢ height = "100" style = "border:1px solid black">
➢ </canvas>
➢ <!-- canvas Tag ends here -->
➢ </body>
➢ </html>
Example: In this example, we simply display the current location with the help of latitude
and longitude via HTML Geolocation.
• HTML
• <!DOCTYPE html>
• <html>
• <body>
• <p>Displaying location using Latitude and Longitude</p>
• <button class="geeks" onclick="getlocation()">
• Click Me
• </button>
• <p id="demo1"></p>
• <script>
• var variable1 = document.getElementById("demo1");
• function getlocation() {
• navigator.geolocation.getCurrentPosition(showLoc);
• } function
• showLoc(pos) {
• variable1.innerHTML =
• "Latitude: " +
• pos.coords.latitude +
• "<br>Longitude: " +
• pos.coords.longitude;
• }
• </script>
• </body>
• </html> Output:
The Media query in CSS is used to create a responsive web design. It means that the view of
a web page differs from system to system based on screen or media types. The breakpoint
specifies for what device-width size, the content is just starting to break or deform.
A media query consist of a media type that can contain one or more expression which can
be either true or false. The result of the query is true if the specified media matches the
type of device the document is displayed on. If the media query is true then a style sheet is
applied.
Example: This example illustrates the CSS media query with the different devicewidth for
making it responsive.
• HTML
• <!DOCTYPE html>
• <html>
• <head>
• <title>CSS media query</title>
• <style> body { text-align: center;
• }
• .gfg {
• font-size: 40px;
• font-weight: bold;
• color: green;
• }
• @media screen and (max-width:800px) {
• body { text-align: center;
• background-color: green;
• } .gfg {
• font-size: 30px;
• font-weight: bold;
• color: • background-color:
• white; blue;
• } .geeks • }
• { color: white; • }
• } • </style>
• } • </head>
• @media screen and (max-width:500px) {
• body { text-align: center;
5) Explain features of Django Framework
Django is a web application framework written in Python programming language. It is based
on MVT (Model View Template) design pattern. The Django is very demanding due to its
rapid development feature. It takes less time to build application after collecting client
requirement. Features of Django:-
1. Rapid Development
2. Secure
3. Scalable
4. Fully loaded
5. Versatile
6. Open Source
7. Vast and Supported Community
Rapid Development:-Django was designed with the intention to make a framework which
takes less time to build web application. The project implementation phase is a very time
taken but Django creates it rapidly.
Secure:-Django takes security seriously and helps developers to avoid many common
security mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc.
Its user authentication system provides a secure way to manage user accounts and
passwords.
Scalable:-Django is scalable in nature and has ability to quickly and flexibly switch from
small to large scale application project.
Fully loaded:-Django includes various helping task modules and libraries which can be used
to handle common Web development tasks. Django takes care of user authentication,
content administration, site maps, RSS feeds etc.
Versatile:-Django is versatile in nature which allows it to build applications for different-
different domains. Now a days, Companies are using Django to build various types of
applications like: content management systems, social networks sites or scientific
computing platforms etc.
• The AJAX application eliminates the start-stop-start-stop nature or the click, wait,
and refresh criteria of the client-server interaction by introducing intermediary layer
between the user and the Web server.
• Traditional Web Applications are those applications that perform most of the
application logic on the server side. They consist of a Web browser on the client side
and a Web server (Apache HTTP Server). Ex: static web HTML pages.
• Traditional web apps should be used for creating web applications that must work in
browsers that support JavaScript just partially or not at all.
Some Features Of Traditional Web Applications:
1. They are used when our application has straightforward client-side requirements
that may be read-only.
2. Traditional Web Applications should be utilized when our applications must run in
browsers that do not support JavaScript.
3. Minimal Client-Side Application Behavior.
8) Architecture of JSON Mashups
1. Flow of JSON mashups that use Dynamic Script method goes as follows:
2. The flow of the process starts with the browser sending request to the server by using
HTTP GET.
3. The Web Server responds with a page that includes the following couple of important
JavaScript functions:
4. A parsing function that expects JavaScript objects to be parameters.
5. The Dynamic Script method is the core of the initiation script through which a new script
tag is added to the page, specifying the source for that script tag to be the Uniform
Resource Locator (URL) at some partner site.
6. The source code for the new script tag gets loaded by the browser.
7. Amazon receives an HTTP Get request sent from the browser using the loaded script.
8. A JavaScript object, after being serialized into a JSON Object, is served by the partner
site.
9. A function call to the render function wraps the JSON script, and the JavaScript entirely
becomes the content for the script tag.
10. The new piece of JavaScript is tried for execution by the browser, which calls the render
method from step 3.
11. The server invokes the render method and evaluates the JSON script, which is converted
into a JavaScript object. The data contained in the render method is pushed into the
page after the render method, which uses the new JavaScript object in its execution.
9) Extensible Markup Language (XML)
Extensible Markup Language (XML) is a markup language that defines a set of rules for
encoding documents in a format that is both human-readable and machine-readable. The
design goals of XML focus on simplicity, generality, and usability across the Internet. It is a
textual data format with strong support via Unicode for different human languages.
Although the design of XML focuses on documents, the language is widely used for the
representation of arbitrary data structures such as those used in web services.
1. XML stands for extensible Markup Language
2. XML is a markup language like HTML
3. XML is designed to store and transport data
4. XML is designed to be self-descriptive
EXAMPLE :
Syntax:
• Performance - RIAs can often perform better than traditional applications on the
basis of the characteristics of network and applications, performance of server also
improved by offloading possible processing work to the client system and also
perceived performance in terms of UI responsiveness and smoother visual
transitions and animations are key aspects of any RIA.
• Offline use - When connectivity is unavailable, it might still be possible to use an RIA.
An RIA platform let the user work with the application without connecting to the
Internet and synchronizing it automatically when the user goes live.
• Consistency of look and feel - With RIA tools, the user interface and experience with
different browsers, devices and operating systems can be more carefully controlled
and made consistent.
• Security - RIAs should be as secure as any other web application, and the framework
should be well equipped to enforce limitations appropriately when the user lacks the
required privileges, especially when running within a constrained environment such
as a sandbox.
• Advanced Communications - Sophisticated communications with supporting servers
through optimized network protocols can considerably enhance the user experience.
• Rapid Development - An RIA Framework should facilitate rapid development of a rich
user experience through its easy-to-use interfaces in ways that help developers.
• Direct Interaction - An RIA can use a wider range of controls that allow greater
efficiency and enhance the user experience. In RIAs, for example, users can interact
directly with page elements through editing or drag-and-drop tools. They can also do
things like pan across a map or other image.
• Better Feedback - Because of their ability to change parts of pages without reloading,
RIAs can provide the user with fast and accurate feedback, real-time confirmation of
actions and choices, and informative and detailed error messages.
14) Embedding Audio
• HTML5 supports <audio> tag which is used to embed sound content in an HTML or
XHTML document as follows.
<audio src = "foo.wav" controls autoplay>
Your browser does not support the <audio> element.
</audio>
• The current HTML5 draft specification does not specify which audio formats browsers
should support in the audio tag. But most commonly used audio formats are ogg, mp3
and wav.
• You can use <source&ggt; tag to specify media along with media type and many other
attributes. An audio element allows multiple source elements and browser will use the
first recognized format −
➢ <!DOCTYPE HTML>
➢ <html>
➢ <body>
➢ <audio controls autoplay>
➢ <source src = "/html5/audio.ogg" type = "audio/ogg" /> <source src =
"/html5/audio.wav" type = "audio/wav" /> Your browser does not support the
<audio> element.
➢ </audio>
➢ </body> </html>
<video src = "foo.mp4" width = "300" height = "200" controls> Your browser does not
support the <video> element.
</video>
• The current HTML5 draft specification does not specify which video formats browsers
should support in the video tag. But most commonly used video formats are −
• Ogg − Ogg files with Thedora video codec and Vorbis audio codec.
• mpeg4 − MPEG4 files with H.264 video codec and AAC audio codec.
• You can use <source> tag to specify media along with media type and many other
attributes. A video element allows multiple source elements and browser will use the
first recognized format −
➢ <!DOCTYPE HTML>
➢ <html>
➢ <body>
➢ <video width = "300" height = "200" controls autoplay>
➢ <source src = "/html5/foo.ogg" type ="video/ogg" />
➢ <source src = "/html5/foo.mp4" type = "video/mp4" /> Your browser does not
support the <video> element.
➢ </video>
➢ </body> </html>
<!DOCTYPE html>
<html>
<head>
<title>Background Color Changer</title>
<script lang="text/javascript"> function bgcolor()
{ loopID = window.setTimeout("bgcolor()",500); // 500 milliseconds delay var index
= Math.floor(Math.random() * 10); var ColorValue = "FFFFFF"; // default color -
white (index = 0) if(index == 1)
ColorValue = "FFCCCC"; //peach if(index == 2)
ColorValue = "CCAFFF"; //violet if(index == 3)
ColorValue = "A6BEFF"; //lt blue if(index == 4)
ColorValue = "99FFFF"; //cyan if(index == 5)
ColorValue = "D5CCBB"; //tan if(index == 6)
ColorValue = "99FF99"; //lt green if(index == 7)
ColorValue = "FFFF99"; //lt yellow if(index == 8)
ColorValue = "FFCC99"; //lt orange if(index == 9)
ColorValue = "CCCCCC"; //lt grey
document.getElementsByTagName("body")[0].style.backgroundColor = "#" +
ColorValue;
} function stopcolor()
{ document.body.style.backgroundColor="white"; clearTimeout(loopID);
}
</script>
17) PHP String Functions
•A string is a collection of characters. String is one of the data types
supported by PHP.
• The PHP string functions are part of the PHP core. No installation is
required to use these functions.
• PHP has a vast selection of built-in string handling functions that allow
you to easily manipulate strings in almost any possible way.
• The most common string functions are as follows:
1. Function strlen() - To count the number of characters in a string strlen()
function is used.
<?php
$str = "Ques10"; echo "The length of string is:".strlen($str);
?>
// Displays: The length of string is:6
<?php
$oldstr = "The cat was black";
$newstr = str_replace("black", "white", $oldstr); echo
$newstr;
?>
// Displays: The cat was white
<?php
$str = “Ques10 ”
Echo “The Repeated string is:”.str_repeat($str , 4);
?>
// Displays: The Repeated string is: Ques10 Ques10 Ques10 Ques10
<?php
echo strrev("Hello world!");
?>
// Displays: !dlrow olleH
18) Javascript Built In Objects
JavaScript has several built-in or core language objects. These built-in objects are
available regardless of window content and operate independently of whatever page
your browser has loaded.
1. Array Object
• Multiple values are stored in a single variable using the Array object.
• In JavaScript, an array can hold different types of data types in a single slot,
which implies that an array can have a string, a number or an object in a single
slot.
2. Boolean Object
• The Boolean object is wrapper class and member of global objects.
• It is used to convert a non-Boolean value to a Boolean value (true or false).
• If the Boolean object has no initial value or if it is 0, -0, null, "", false,
undefined, or NaN, the object is set to false. Otherwise it is true (even with
the string "false")! Date Object
• At times when user need to access the current date and time and also past
and future date and times. JavaScript provides support for working with dates
and time through the Date object.
• The Date object provides a system-independent abstraction of dates and
times.
3. Math Object
• The Math object is used to perform simple and complex arithmetic
operations.
• The Math object provides a number of properties and methods to work with
Number values
4. Number Object
• The Number objects represents numerical date, either integers or floating-
point numbers.
• A Number objects are created using the Number() constructor var num = new
number(value);
5. String Object
• in JavaScript, all strings are represented as instances of the String object.
• The String object is wrapper class and member of global objects.
6. RegExp Object
• RegExp object used to validate the pattern of characters.
• RegExp define methods that use regular expressions to perform powerful
patternmatching and search and replace functions on text.
19) List And Explain Various Features Of React
React is a JavaScript Library created by Facebook for creating dynamic and interactive
applications and building better UI/UX design for web and mobile applications. React is an
open-source and component-based front-end library. React is responsible for the UI design.
React makes code easier to debug by dividing them into components.
Features of React:
As displayed in the above diagram, there are three states of a servlet: new, ready and end.
The servlet is in new state if servlet instance is created. After invoking the init() method,
Servlet comes in the ready state. In the ready state, servlet performs all the tasks. When the
web container invokes the destroy() method, it shifts to the end state.
1. Servlet class is loaded
The classloader is responsible to load the servlet class. The servlet class is loaded when the
first request for the servlet is received by the web container.
The web container calls the init method only once after creating the servlet instance. The
init method is used to initialize the servlet. It is the life cycle method of the
javax.servlet.Servlet interface. Syntax of the init method is given below:
Servlets are grouped under the Advanced Java tree that are used to create dynamic web
applications. Servlets are robust in nature, well scalable and are primarily used in developing
server-side applications. If we go a little back in time, we would be able to witness that
before the introduction of servlets, CGI (Common Gateway Interface) were used. Amid
several indigenous tasks that a servlet is capable of doing, dynamically performing client
requests and responses are most common. Other tasks that a servlet can do effectively are:
Talking about the types of servlets, there are primarily two types, namely:
1. Generic Servlets
2. HTTP Servlets
There are three potential ways in which we can employ to create a servlet:
EventTargetXMLHttpRequestEventTargetXMLHttpRequest
Despite its name, XMLHttpRequest can be used to retrieve any type of data, not just XML.
If your communication needs to involve receiving event data or message data from a server,
consider using server-sent events through the EventSource interface. For fullduplex
communication, WebSockets may be a better choice
The XMLHttpRequest object is used to exchange data with a server.
Send a Request To a Server
To send a request to a server, we use the open() and send() methods of the
XMLHttpRequest object:
Method Description
open(method, url, async) Specifies the type of request method: the type of
request: GET or POST url: the server
(file)location async: true (asynchronous) or false (synchronous)
Cookies
A cookie is a unique ID assigned to clients when they first visit a website. Whenever
this client connects to the server again, it will send the cookie that was given earlier
by the server. The server will then recognize that it is the same user.
session Tracking tracks a user’s requests and maintains their state. It is a mechanism
used to store information on specific users and in order to recognize these user’s
requests when they connect to the web server.