Web Technologies
Web Technologies
Web Technologies
1)
a) What is an IP address? What are its types? Explain.
Ans:
Among them, public and private addresses are based on their location of the
network private, which should be used inside a network while the public IP is
used outside of a network.
Public IP Addresses
A public IP address is an address where one primary address is associated with
our whole network. In this type of IP address, each of the connected devices has
the same IP address. This type of public IP address is provided to our router by
our ISP.
Private IP Addresses
A private IP address is a unique IP number assigned to every device that connects
to our home internet network, which includes devices like computers, tablets,
smartphones, which is used in our household.
It also likely includes all types of Bluetooth devices we use, like printers or
printers, smart devices like TV, etc. With a rising industry of internet of things
(IoT) products, the number of private IP addresses we are likely to have in our
own home is growing.
Dynamic IP address:
Dynamic IP addresses always keep changing. It is temporary and are allocated to
a device every time it connects to the web. Dynamic IPs can trace their origin to
a collection of IP addresses that are shared across many computers.
Static IP Addresses
A static IP address is an IP address that cannot be changed. In contrast, a dynamic
IP address will be assigned by a Dynamic Host Configuration Protocol (DHCP)
server, which is subject to change. Static IP address never changes, but it can be
altered as part of routine network administration.
Static IP addresses are consistent, which is assigned once, that stays the same
over the years. This type of IP also helps us procure a lot of information about a
device.
b) What is <img> tag? Why is it used? How can you insert an image
with rounded corners?
Ans:
HTML <img> tag is used to add image inside webpage/website. Nowadays
website does not directly add images to a web page, as the images are linked to
web pages by using the <img> tag which holds space for the image.
Syntax
<img src="" alt="" width="" height="">
The CSS property border-radius adds rounded corners on images. We can round
all of the image's corners or just select corners, vary the radius on different corners
or display an image in the shape of an oval or a circle.
2)
a) What is cascading style sheet (CSS)? How can you insert CSS in
HTML Page?
Ans:
Cascading Style Sheets, fondly referred to as CSS, is a simple design language
intended to simplify the process of making web pages presentable.
CSS handles the look and feel part of a web page. Using CSS, we can control the
color of the text, the style of fonts, the spacing between paragraphs, how columns
are sized and laid out, what background images or colors are used, layout
designs,variations in display for different devices and screen sizes as well as a
variety of other effects.
CSS is easy to learn and understand but it provides powerful control over the
presentation of an HTML document. Most commonly, CSS is combined with the
markup languages HTML or XHTML
JavaScript Location Object has many properties using which we can access the
various components of a webpage's URL and even change it.
Example:
Property Description
href Represents a string specifying the entire URL, for instance
http://www.javascriptstudytonight.com:80/order.cgi?batch=1#intro
protocol Represents a String at the begining of a URL to the first
colon(:),which specifies the Method of access to the URL , for
instance http: or https:
host Represents a String consisting of hostname and port Strings,for
instance:- www.javascriptstudytonight.com:80
Location Object methods refers to the functions created inside the location
interface which can be used to perform various operations on the URL like
reload it, change it, etc.
Example:
Method Description
assign() Loads a new Document in the
Browser
reload() Reloads the current document that is
contained in location.href property.
replace() Replaces the current document with
the specified new one. In addition,
you cannot navigate back to the
previous document using the
Browser's back button.
3)
a) Explain characteristics of JavaScript.
Ans:
1. JavaScript Lives in a Web Page
2. JavaScript is not server side language. It is client side language because it
is interpreted and run on the browser.
3. It is weakly typed because it does not need to specify datatypes to declare
variable (int, float, double etc) like c/c++.
4. It is not programming language. It Interpreted language because browsers
are interpret it.
5. JavaScript is case sensitive.
6. Semicolon(;) is optional
7. String can be enclosed by using single quote (‘) or double quote(“”)
8. // is used to specify single line comment and /* ... */ is used to specify
multiline comment.
b) What is event handling? How can you add an onclick event in HTML
page?
Ans:
Change in the state of an object is known as event i.e. event describes the
change in state of source. Events are generated as result of user interaction
with the graphical user interface components. For example, Clicking on a
button, moving the mouse, entering a character through keyboard, selecting
an item from list, scrolling the page are the activities that causes an event to
happen.
HTML <Button onClick=" ">
The Html <button onclick=" "> is an event attribute, which executes a script
when the button is clicked. This attribute is supported by all browsers. It is
also used to call a function when the button is clicked.
Syntax
<button onclick=" single value script">
SET II
4)
a) What is XMLHttpRequest object? Explain with an example.
Ans:
XMLHttpRequest (XHR) objects are used to interact with servers. We can
retrieve data from a URL without having to do a full page refresh. This enables
a Web page to update just part of a page without disrupting what the user is
doing. XMLHttpRequest is used heavily in AJAX programming. Despite its
name, XMLHttpRequest can be used to retrieve any type of data, not just
XML
XMLHttpRequest Example
Name: Suggestions:
Sending an XMLHttpRequest
Example
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// Typical action to be performed when the document is ready:
document.getElementById("demo").innerHTML =
xhttp.responseText;
}
};
xhttp.open("GET", "filename", true);
xhttp.send();
b) What are PHP variables? How you declare them? What are the
naming conventions for PHP variables?
Ans:
Variables in a program are used to store some values or data that can be used
later in a program. The variables are also like containers that store character
values, numeric values, memory addresses, and strings. PHP has its own way
of declaring and storing variables. There are a few rules, that need to be
followed and facts that need to be kept in mind while dealing with variables
in PHP.
In PHP variable we be declared as: $var_name = value;
Example:
<?php //
Declaring variables
$txt = "Hello World!";
$number = 10;
// Displaying variables value
echo $txt; // Output: Hello World!
echo $number; // Output: 10
?>
2. The XML document that we'll load into this HTML has the following
structure. Note that the nodes for Employees 3 through 6 are collapsed
in the following image.
3. After the page loads, use JavaScript to run a function
called buildTable(), which in turn will run a function to populate the
table rows.
window.addEventListener("load", function() {
getRows();
});
4. Write the getRows() function to retreive the XML data using AJAX. If
the request succeeds, run a function called showResult().
function getRows() {
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("get", "Employees", true);
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
showResult(this);
}
};
xmlhttp.send(null);
}
5. Write showResult(), which will take the AJAX response as a parameter
function showResult(xmlhttp) {
}
6. Inside the showResult() function, extract the XML document from the
response object parameter
function showResult(xmlhttp) {
var xmlDoc = xmlhttp.responseXML.documentElement;
}
12. Run the script by opening it in a web browser. We can test it locally,
without a server, by creating a file named Employees.xml and changing
the URL in the XMLHttpRequest open() method to Employees.xml.
our finished HTML page and script should look like this:
b) What is a recordset object? Explain with example.
Ans:
A Recordset object represents the records in a base table or the records that
result from running a query. We use Recordset objects to manipulate data in
a database at the record level. When we use DAO objects, you manipulate data
almost entirely using Recordset objects. All Recordset objects are
constructed using records (rows) and fields (columns). There are five types
of Recordset objects:
With dbsNorthwind
With rstLoop
Debug.Print " " & .Name
End With
Next rstLoop
rstTable.Close
rstDynaset.Close
rstSnapshot.Close
rstForwardOnly.Close
.Close
End With
End Sub
6)
a) Explain comparison operators used in PHP.
Ans:
The Word Comparison in Comparison Operators in PHP itself says that the
operators are generally used for comparing any two values/variable values
(variable values can be a string or a number or any other to compare). Equal,
Identical, Not Equal, Not identical, Greater than, Less than, Greater than or
equal to, Less than or equal to are some of the comparison operator names to
compare any two types of similar type of values based on our requirement.
Operator Name Example Result
== Equal $x == $y TRUE if $x is exactly equal to
$y
=== Identical $x === $y TRUE if $x is exactly equal to
$y, and they are of the same
type.
!= Not equal $x != $y TRUE if $x is exactly not
equal to $y.
<> Not equal $x <> $y TRUE if $x is exactly not
equal to $y.
!== Not identical $x !== $y TRUE if $x is not equal to $y,
or they are not of the same
type.
< Less than $x < $y TRUE if $x (left-hand
argument) is strictly less than
$y (right-hand argument).
> Greater than $x > $y TRUE if $x (left hand
argument) is strictly greater
than $y (right hand argument).
<= Less than or $x <= $y TRUE if $x (left hand
equal to argument) is less than or
equal to $y (right hand
argument).
>= Greater than or $x >= $y TRUE if $x is greater than or
equal to equal to $y.
<%
'check for form submission and then allow
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
fact = 1
'get the value from input text box 'number'
number = Request.form("number")
Response.Write("Factorial of "+number+"<br><br>")
i=1
Do until i = number
'formula to calculate factorial is to
'multiply the iterator i value with fact value.
fact = fact * i