Internet Technology - Summary
Internet Technology - Summary
Internet Technology - Summary
• HTML5
• CSS
• JS
• PHP
Introduction:
NUTS & BOLTS View:
Q1) What is the internet as NUTS & BOLTS view?
• millions of connected computing devices: hosts / end systems.
• Network apps.
• Communication links → fiber, copper, satellite, …etc.
• Routers to forward Packets.
• Protocols that controls sending & receiving of messages→ TCP, UDP, IP, HTTP, FTP, TFTP, Telnet.
• Internet (network of networks).
Q3) What is the Difference between TCP/IP, UDP transport layer protocols?
UDP TCP
Connectionless Connection Oriented
Unreliable Reliable
Faster Slower
Lower header overhead Higher header overhead
No Acknowledgment Acknowledgment
Very basic error checking Extensive error checking
No sequencing of data packets Sequencing of data packets
No retransmission Retransmission of lost packets
VOIP Email
Chapter 1 – World Wide Web:
Q.3 Explain the Domain Name System, function & components, according to below diagram
Answer:
• DNS: is a collection of databases, that contain information about domain names and its
corresponding data IP address.
For example, if someone types Tony.com into a web browser, a server behind the scenes will
map that name to the IP address e.g.: 206.19.49.149.
• The Domain name function: its way to identify and allocate computers connected to the internet
and no two organization can have same domain name.
• Components of DNS:
− Name space
− Name servers
− Resolvers
Answer:
• This diagram outlines the process of displaying a web page when www.photoapp.com is typed into the
location bar of the browser for the first time (not cached in DNS cache).
Answer:
Q1) True/False ➔ Because browsers must retain cookies, “Web servers are stateless, not browsers” (True)
(quiz 2020)
Q2) Web servers are stateless, not browsers. Discuss:
Answer:
• Web server is stateless because HTTP requests are independent, so the server can't tell if 2 requests
came from the same browser or user.
• On the other hand, browsers can store stateful information as cookies:
▪ Cookies are name-value pairs stored on the client’s hard disk by a web server in order to be sent
back to the web server in the next HTTP request.
▪ When the web server receives the cookie data, it can tell if the request came from a previous
visitor or not and can personalize the session accordingly.
▪ If the web server doesn’t receive a cookie data, it assumes that the user didn’t visit before, and
then sends name-value pairs to your machine in the header for the web server it sends.
Q3) Suppose user enters URL www.MTI.edu/CSDepartment/home.index, (contains text and references to 5 jpeg
images). Show HTTP request & response messages order, in both Non-Persistent & Persistent HTTP.
Answer:
• Non-Persistent (HTTP/1.0):
➢ Will open a new TCP connection for every single request/response pair.
1. Initial TCP connection (usually 1 RTT delay):
a. Web user requests for TCP connection at http://www.mti.edu/ on port 80.
b. Web server accepts the TCP connection at port 80 notifying the client.
2. The client sends HTTP request message (containing URL) into TCP connection socket. Message
indicates that client wants object CSDepartment/home.index.
3. Web server receives request message, and forms a response message containing the requested
object and sends message into its socket.
4. Web server closes TCP connection.
5. Client receives the response message containing html file and then displays html. Parsing the
html file, it finds 5 referenced jpeg objects.
6. It repeats steps 1→5 for each 5 jpeg objects.
b. Describe the Disadvantage of having this line on a HTTP GET response. Given an example of a
HTTP GET response done by your website that it would be inappropriate?
Q.1 “Cache-Control: max-age=2628000”,. Describe the benefit & disadvantages a web application would
get from having that line in a HTTP GET response header.
Answer:
• "max-age" defines the amount of time a file should be cached for, in this statement max-age is
equal to 2628000 seconds.
• Here, cache-control: max-age=262800 means that the returned resource is valid for
262800 seconds, after which the browser has to request a newer version.
• Benefits is for ensuring security and privacy as for banking websites or to always keep your pages
up to date to refresh frequently to see latest feeds.
• Disadvantages is that it puts a lot of load on the server because of repeated requests instead of
using cached copy with user.
Q.7 What is web cache? How caches keep up-to-date copies to retrieve? Explain using the two different
cases shown in the following figure between client / server http msg.
Answer:
• Web cache: Web caching is the storage of Web objects near the user to allow fast access, thus
improving the user experience of the Web surfer the main goal is satisfy client request without
involving origin server.
• Examples of some Web objects:
▪ Cache-friendly content (Tend to change infrequently):
o Logos and brand images
o Non-rotating images in general (navigation icons, for example)
o Style sheets
o General JavaScript files
o Downloadable Content
o Media Files
▪ Some items that you have to be careful in caching are:
o HTML pages
o Rotating images
o Frequently modified JavaScript and CSS
o Content requested with authentication cookies
▪ Some items that should almost never be cached are:
o Assets related to sensitive data (banking info, etc.)
o Content that is user-specific and frequently changed
Describe the mechanism used by a web application to prevent its session cookies from being used by a
web application from a different company. (& Exam Model 3 Q.3.4)
What are cookies? Explain why major web sites use cookies (Exam Model 4 Q.3.3)
Answer:
• The same-origin policy is a critical security mechanism that restricts how a document or script
loaded from one origin can interact with a resource from another origin. It helps isolate potentially
malicious documents, reducing possible attack vectors.
• Two URLs have the same origin if the protocol, port (if specified), and host are the same for both.
You may see this referenced as the "scheme/host/port tuple", or just "tuple". (A "tuple" is a set of
items that together comprise a whole — a generic form for double/triple/quadruple/quintuple/etc.)
URL Outcome Reason
http://store.company.com/dir2/other.html Same origin Only the path differs
http://store.company.com/dir/inner/another.html Same origin Only the path differs
https://store.company.com/page.html Failure Different protocol
http://store.company.com:81/dir/page.html Failure Different port (http:// is port 80 by default)
http://news.company.com/dir/page.html Failure Different host
What are Internet Cookies and What Do They Do? Mention cookies components.
Answer:
• Cookies: Cookies are small files which are stored on a user's computer. They are designed to hold
a modest amount of data specific to a particular client and website and can be accessed either by the
web server or the client computer. This allows the server to deliver a page tailored to a particular
user (like advertisings).
• Cookies Components:
1. Cookie Counter Allows web developer to increase or decrease the value of a number in
a cookie.
2. Cookie Counter Allows web developer to redirect a visitor based on a predefined cookie
Redirect count value.
3. Cookie Delete Allows web developer to delete a cookie that has been set.
4. Cookie Expiration Allows web developer to set the period of time a cookie will reside on
a visitor's computer.
5. Cookie Redirect Allows web developer to know if a cookie is present, and if not, to
redirect to another page.
6. Cookies Enabled Checks to see if a visitor's browser has cookies enabled and redirects
to another page if it doesn't.
7. Display Value Allows web developer to display, anywhere on a page, the value which
was set in a cookie.
8. Get Value from Allows web developer to get a value from a form field (such as name,
Form Field address, etc.), to set in a cookie for future use.
9. Get Value from Allows web developer to use a value generated in a prompt box to set
Prompt Message a cookie for future use.
10. Set Value Allows web developer to create a value, such as date and time of visit,
to set in a cookie for future use.
11. Store Value in Allows web developer to store a set value into a new form.
Form Field
12. Use Value in Allows web developer to use a value in a message box, an alert box, a
Messages prompt message, or confirmation box.
2.6 E-mail:
Q.2What are the main components of the email? Briefly explain the basic functions of the mail user agent.
(& Model 4 Q.1.2)
Answer:
• Email has three major components:
▪ User agents.
▪ Mail servers.
▪ SMTP (Simple Mail Transfer Protocol.
• Email user agent system supports five basic functions:
▪ Composition
▪ Transfer
▪ Reporting
▪ Display
▪ Disposition
Q.3 Discuss the main differences between POP3 & IMAP Protocols
Answer:
• POP3 (Post Office Protocol):
▪ Emails are stored on a single device
▪ Sent emails are stored on a single device
▪ Emails can be accessed from a single device
• IMAP(Internet Messaging Access Protocol):
▪ Emails are stored on server
▪ Sent messages are stored on server
▪ Messages can be synched and accessed from multiple devices
Chapter 3 – HTML5 – CSS3:
3.1 HTML
& 3.2 HTML5:
Q1) Write the HTML code to generate the following lists using:
a) Alpha
b) Beta
i. Tilde
ii. Lambda
c) Zeta
<!-- types: 1|a|A|i|I -->
<ol type="a">
<li>Alpha</li>
<li>Beta</li>
<ol type="i">
<li>Tilde</li>
<li>Lambda</li>
</ol>
<li>Zeta</li>
</ol>
Q2) Select one or more: Tags of the head section in HTML5 (quiz 2020)
a) <body> <href> ( )
b) <style> <tr> ( )
c) <meta> <link> (✓)
d) <link> <style> (✓)
Q3) Write an HTML code to create the following form:
Answer (layout using table) (Obsolete method)(CSS is optional):
<html>
<head>
<title>Fruit</title>
<style>
* {
margin: 0;
}
input {
margin-bottom: 10px;
}
td {
vertical-align: top;
padding: 0 9px;
}
td[data-error]::after {
content: attr(data-error);
position: absolute;
margin-left: 10px;
color: red;
}
</style>
</head>
<body style="background-color: #ffff99; text-align: center;">
<h1 style="background-color: #ffcc00;">The World Of Fruit</h1>
<h2 style="margin-bottom: 20px;">Fruit survey</h2>
<form style="margin: center;">
<table>
<tr style="text-align: right;">
<td><label for="name"> Name: </label></td>
<td><input id="name" name="name" type="text" /></td>
</tr>
<tr style="text-align: right;">
<td><label for="Address"> Address: </label></td>
<td><input id="Address" name="Address" type="text" /></td>
</tr>
<br />
</form>
<script>
const email = document.getElementById('email')
email.addEventListener('blur', function () {
email.value == '' ? email.parentElement.setAttribute('data-error', 'Missing')
: email.parentElement.removeAttribute('data-error')
})
</script>
</body>
</html>
Another answer (layout using Grid):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The world of fruit</title>
<style>
* {
box-sizing: border-box;
margin: 0;
}
body {
background-color: #ffff99;
}
.page-title {
text-align: center;
background-color: #ffcc00;
}
.form-title {
text-align: center;
padding-block: 0.8rem;
}
.grid {
display: grid;
column-gap: 0.6rem;
row-gap: 0.8rem;
grid-template-columns: repeat(2, auto);
justify-content: center;
}
.grid > :nth-child(odd) {
text-align: right;
}
[data-error]::after {
content: attr(data-error);
position: absolute;
margin-left: 10px;
color: red;
}
</style>
</head>
<body>
<h1 class="page-title">The world of fruit</h1>
<h2 class="form-title">Fruit Survey</h2>
<form action="" class="grid">
<label for="name">Name</label>
<input type="text" id="name" name="name" />
<label for="address">Address</label>
<input type="text" id="address" name="address" />
<label for="email">Email</label>
<div>
<input type="text" id="email" name="email" />
</div>
<!-- Radio Group -->
<p>
How Many pieces of fruit <br />
do you eat per day?
</p>
<div>
<div>
<input type="radio" id="f1" name="fruit-num" value="0" />
<label for="f1">0</label>
</div>
<div>
<input type="radio" id="f2" name="fruit-num" value="1" />
<label for="f2">1</label>
</div>
<div>
<input type="radio" id="f3" name="fruit-num" value="2" />
<label for="f3">2</label>
</div>
<div>
<input type="radio" id="f4" name="fruit-num" value="More than 2" />
<label for="f4">More than 2</label>
</div>
</div>
<!-- Select Menu -->
<p>My favorite fruit</p>
<div>
<select name="fav-fruit" size="4">
<option value="apple">Apple</option>
<option value="banana">Banana</option>
<option value="plum">Plum</option>
<option value="pomegranate">Pomegranate</option>
<option value="orange">Orange</option>
<option value="mango">Mango</option>
</select>
</div>
Output:
Q4) Write an HTML code to create the following form :
Answer (layout using table) (Obsolete method):
<html>
<head>
<title>Blue Developer Directory</title>
<style>
* {margin: 0;}
<tr>
<td style="text-align: right;">
<p style="width: 180px;">Best time to call</p>
</td>
<td>
<input type="radio" id="s0" name="pof" />
<label for="s0"> Morning </label>
<tr>
<td>
<p style="text-align: right;" for="fav">Budget</p>
</td>
<td>
<select name="budget">
<option value="none" disabled selected>Select one</option>
<option value="high">High</option>
<option value="low">Low</option>
</select>
</td>
</tr>
<tr>
<td>
Services Needed:
<br />
(Check all that apply)
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="html" />
<label for="like">
Html
</label>
<input type="checkbox" id="php" />
<label for="like">
PHP
</label>
</td>
</tr>
<tr>
<td>
<input type="checkbox" id="aps" />
<label for="like">
ASP
</label>
<tr>
<td>
<input type="checkbox" id="cpp" />
<label for="like">
C++
</label>
<input type="checkbox" id="design" />
<label for="like">
Design
</label>
</td>
</tr>
<tr>
<td><input type="submit" value="submit form" /></td>
</tr>
</table>
<br />
</form>
</body>
</html>
Answer (Using Grid Layout):
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Blue Developer Directory</title>
<style>
* {margin: 0;}
body {background-color: lightblue;}
.page-title {background-color: blue; color: white;}
.form-title {padding-block: 0.8rem;}
.grid {
display: grid;
column-gap: 0.3rem;
row-gap: 0.8rem;
grid-template-columns: repeat(2, auto);
justify-content: start;
justify-items: start;
}
.lg-gap {column-gap: 3rem;}
form {padding-inline-start: 0.5rem;}
</style>
</head>
<body>
<h1 class="page-title">Blue Developer Directory</h1>
<h2 class="form-title">Contact Us</h2>
<form action="">
<p>Please use this form to contact a member of our website team</p>
<div class="grid lg-gap">
<label for="name">Full Name:</label>
<input type="text" name="name" id="name" />
<p>Budget</p>
<div>
<select name="budget">
<option value="none" disabled selected>Select one</option>
<option value="high">High</option>
<option value="low">Low</option>
</select>
</div>
</div>
<p> Services Needed: <br /> (Check all that apply) </p>
<div class="grid">
<div>
<input type="checkbox" value="html" />
<label for="">html</label>
</div>
<div>
<input type="checkbox" value="PHP" />
<label for="">PHP</label>
</div>
<div>
<input type="checkbox" value="ASP" />
<label for="">ASP</label>
</div>
<div>
<input type="checkbox" value="Java" />
<label for="">Java</label>
</div>
<div>
<input type="checkbox" value="C++" />
<label for="">C++</label>
</div>
<div>
<input type="checkbox" value="Design" />
<label for="">Design</label>
</div>
</div>
</form>
</body>
</html>
Q5) Write the HTML5 code to add video element to your webpage. Considering alternate video resource.
Write EMPTY functions script to use video built-in controls (play, pause, seek). (& Exam model 4
Q.2.2)
Answer:
<!DOCTYPE html>
<html>
<head>
<title>Video</title>
<script>
function play() {
document.getElementById('vid').play()
}
function pause() {
document.getElementById('vid').pause()
}
function seek() {
document.getElementById('vid').pause()
document.getElementById('vid').currentTime = document.getElementById('vid').currentTime + 10
document.getElementById('vid').play()
}
</script>
</head>
<body>
<video id="vid" width="320" height="240">
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
<br />
<button > <button > <button > </body>
</html>
Q6) Write an HTML to produce the following table with background Yellow & text color red.
Answer:
<!DOCTYPE html>
<html>
<head>
<title>Table</title>
<!-- Table Style -->
<style>
table,
th,
td {
border: 1px double red;
background-color: yellow;
}
</style>
</head>
<body>
<table>
<!-- Table Head -->
<thead>
<th>First Column</th>
<th>Second Column</th>
<th>Third Column</th>
</thead>
<!-- Table Body -->
<tbody>
<!-- row 1 -->
<tr>
<td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
<td>Row 1 Cell 3</td>
</tr>
<!-- row 2 -->
<tr>
<td>Row 2 Cell 2</td>
<td>Row 2 Cell 3</td>
</tr>
<!-- row 3 -->
<tr>
<td colspan="3">Row 3 Spans along 3 Columns</td>
</tr>
</tbody>
</table>
</body>
Output:
</html>
3.3 CSS:
True or false? ➔When you want to style set of documents with same style, it’s better to use External
CSS (True) (quiz 2020)
What is CSS? What are the major advantages of using an external CSS file in Web Pages?
Answer:
• Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation
of a document written in a markup language like HTML.
• External CSS can be applied to multiple documents while being managed from a single style
sheet. This keeps code DRY and improves efficiency and convenience.
Write two CSS files sty1, sty2, for Blue theme and Grey theme.
Answer:
Write HTML tags show how to use alternate styles and printed version.
Answer:
• Letter spacing:
p {
font-size: smaller;
letter-spacing: 1em;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document</title>
<link rel="stylesheet" type="text/css" href="style1.css" title="Style 1" />
<link rel="alternate stylesheet" type="text/css" href="style2.css" title="Style 2" />
</head>
<body></body>
</html>
<head>
<title>CSS</title>
<!-- Adding external CSS-->
<link rel="stylesheet" href="mystyle.css" />
<!-- internal CSS -->
<style>
body {
background-color: linen;
}
</style>
</head>
</html>
Chapter 4 – Script Language:
a) Error ( )
b) 8 ( )
c) 44 (✓)
Q2) In JavaScript, which of the below comments lines are used? (quiz 2020)
a) //,/*……**/ ( )
b) /, /**……/, /* ( )
c) /*……*/, // (✓)
a) Error ( )
b) 8, 9 ( )
c) 8, 18 (✓)
Note:
array.map() method➔ https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Array/map#:~:text=The%20map()%20method%20creat
es,element%20in%20the%20calling%20array.
Q4) Briefly describe the major uses of JavaScript on the client side. (Model 4 Q.4.1)
Answer:
Can validate user input
Can update the webpage without the need to interact with the server.
Allows page to react to user actions other than pushing a “submit” button – more interactivity
Q5) Explain why a web application coding standard might demand that the script tag for including
JavaScript libraries look like: <script src="/library.js"></script> instead of containing the full site information
like: <script src="http://www.site.com/library.js"></script>
Answer:
The first form of the script tag takes protocol, typically http and https and host name from the enclosing
page where the second form hard codes the protocol http and host. If this page is served with https the
second will generate a mixed content problem by fetching code using http. (p.14 q2 3)
Q6) Write a complete program (HTML5 with JavaScript) that display all odd numbers in range N1 to N2.
User is prompted to enter N1 and N2. (& Exam model 2 Q.2.1 + Model 4 Q.4.3)
JS:
const n1 = document.getElementById('n1')
const n2 = document.getElementById('n2')
const displayBtn = document.getElementById('displayBtn')
const resultsContainer = document.getElementById('resultsContainer')
function oddNumsToTable(results) {
let table = document.createElement('table')
let cell, cellText
results.forEach((resultsRow) => {
let row = document.createElement('tr')
cell = document.createElement('td')
cellText = document.createTextNode(resultsRow)
cell.appendChild(cellText)
row.appendChild(cell)
table.appendChild(row)
})
return table
}
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Odd numbers in range</title>
<link rel="stylesheet" href="style.css" />
<script defer src="app.js"></script>
</head>
<body>
<header><h1>Display odd numbers in range</h1></header>
<section>
<form>
<label for="n1">Number1:</label>
<input id="n1" type="number" />
<label for="n2">Number2:</label>
<input id="n2" type="number" />
<aside id="resultsContainer"></aside>
</body>
</html>
CSS (optional):
h1 {
text-decoration: underline;
margin: 35px 0px;
}
aside {
float: right;
width: 35%;
margin-top: 30px;
}
tr:nth-child(even) {
background-color: Gainsboro;
}
tr:nth-child(odd) {
background-color: whitesmoke;
}
tr:first-child {
background-color: gray;
}
td {
font-size: 25px;
padding: 0px 15px;
text-align: center;
}
input[type='number'] {
width: 2rem;
height: 2rem;
appearance: none;
background-color: #ffdb97;
border: 1px solid #ffc514;
}
Q7) Write the output when the below JavaScript code executed:
<script>
var globalVar = 1
function foo(argVar) {
var localVar = 2
return function (arg) {
argVar += arg
localVar += arg
globalVar += arg
document.write('F ', argVar, localVar, globalVar)
document.write('<br>')
}
}
var func1 = foo(1)
var func10 = foo(10)
func1(1)
func10(2)
document.write('G', globalVar)
</script>
Answer:
Output:
F 232
F 1244
G4
Q8) Write JavaScript function to use a function to find (for instance) the highest value in a list of
numbers passed as parameters to function findMax. Use argument object to write your code.
function findMax() {
var max = -Infinity
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] > max) {
max = arguments[i]
}
}
return max
}
• More information about: Argument object:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments
Another Answer (ES6 using rest parameter) (not the required answer, but useful to know):
Note:
https://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Functions/rest_parameters#the_difference_between_rest_parameters_and_the_arguments
_object
function findMax(...numbers) {
let max = -Infinity
for (const num of numbers) if (num > max) max = num
return max
}
HTML
<div id="a">A
<div id="b">B
<div id="d">D</div>
</div>
<div id="c">C</div>
</div>
JavaScript:
function callback(event) {
console.log(event.target.id + ' ' + event.currentTarget.id)
}
a) What would be printed out if the user clicked on the letter ‘d’?
Output:
dd
db
da
b) If the JavaScript changed so that the third argument to each addEventListener() call is true, what
would be printed out if we clicked on the letter ‘c’?
ca
cc
This may help you to understand the above answer:
• bubbling and delegation: https://www.youtube.com/watch?v=6NMSCh3DJug
• The Boolean in addEventListener:
o false = Register the event handler for the bubbling phase.
o true = Register the event handler for the capturing phase.
• capture phase vs bubbling phase:
Answer:
4 undefined 5
var x = 1;
(function (x) {
console.log(x);
x = 3;
})(2);
console.log(x);
Answer:
2
1
Q11) How many alert dialogs will the following JavaScript generate, and what will be displayed in each of
them?
var x = '10'
function f() {
var x = '4'
alert(this.x)
function g() {
alert(x)
}
g()
}
f()
Answer: there will be 2 alert dialogs. The first will display “10”, and the second will display “4”.
Q12) Below you will see some snippets of HTML from a Web page. Fill in the body of the JavaScript
function changeColor so that the color of the text changes in response to the selection made in the
menu.
<style type="text/css">
.a {
color: red;
}
.b {
color: green;
}
.c {
color: blue;
}
</style>
...
<div id="colorText">Select below to change the color of this text</div>
<select > <option value="a">Red</option>
<option value="b">Green</option>
<option value="c">Blue</option>
</select>
<script type="text/javascript">
function changeColor(value) {
//Answer:
Document.getElementById('colorText').className = value
}
</script>
Chapter 5 – Cloud Computing Overview:
Q1) For each of the pieces of a web application implementation listed below, state which parts (Model,
View, or Controller) would the piece be most associated with. Provide a brief justification for all:
تاكد
a) CSS rules → view
b) JavaScript Code→ controller
c) HTML→ view
d) Animations→ view
e) Database data→ model
Q2) Label each of the tasks below with “Model”, “View”, “Controller” to indicate where that task would
typically be implemented in a Web application using MVC architecture.
a) Validate form data → model
b) Make sure a user is logged in → controller
c) Invoke to link to method → view
d) Return a “redirect” to the browser → controller
e) Define event handler to custom form element → view
f) Generate a new session token → controller
g) Invoke the find_all_by_name method → controller
h) Create a “salt” for a password → model
Q3) Why should one prefer public cloud over private cloud? List some obstacles and opportunities for
adoption and growth of cloud computing?
Answer:
Because Public Cloud allows systems and services to be easily accessible to the general public
Q4) why cloud computing platforms work well for web application startup companies that are starting
small but hoping to make it big in a hurry? (& Exam Model 4 Q.1.1.1)
Answer:
One of the main reasons is the pricing model of billing based on resources used. Rather than having to
spend a bunch of money on servers the startup hosted on the cloud’s expenses start low and grow with
the resources used.
Q7) List out few different return types of a M-V-C action method?
Answer:
It’s a collection or group of integrated and networked hardware, software and internet infrastructure (Called a
platform). Using the internet for communication and transport provides hardware, software and networking
services to clients.
These platforms hide the complexity and details of the underlying infrastructure from users and applications by
providing very simple graphical interface or API (Applications Programming Interface).
Disadvantages:
• SECURITY & PRIVACY It is the biggest concern about cloud computing. Since data
management and infrastructure management in cloud is provided by third-party, it is always a
risk to handover the sensitive information to such providers. Although the cloud computing
vendors ensure more secure password protected accounts, any sign of security breach would
result in loss of clients and businesses.
• LOCK-IN It is very difficult for the customers to switch from one Cloud Service Provider
(CSP) to another. It results in dependency on a particular CSP for service.
• ISOLATION FAILURE This risk involves the failure of isolation mechanism that separates
storage, memory, routing between the different tenants.
• MANAGEMENT INTERFACE COMPROMISE In case of public cloud provider, the
customer management interfaces are accessible through the Internet. 164 ???
• INSECURE OR INCOMPLETE DATA DELETION It is possible that the data requested for
deletion may not get deleted. It happens either because extra copies of data are stored but are
not available or disk destroyed also stores data from other tenants.
Q11) Explain how a Content Distribution Network (CDN) can improve the performance of web applications
for users. IS CDN and cloud are the same?
Answer:
5.1 Introduction:
Q.1 What does the web server typically do with the following html fragment: “<a href="#top">Top</a>”
Answer:
• It gets handled in the client browser (The server doesn’t do anything with html fragments).
Question 2:
Discuss the Error Msg below in the figure:
Answer:
• This warning message occurs when items on the following web site (frames, images and other
objects) are referenced in a non-secure manner (http). For example, the page code might include
an image or code that pulls from a non-secure URL.
• To resolve this issue, make sure that the page code does not pull data directly from a non-secure
URL.
Question 3:
Consider the following security attack where an evil server attempts to impersonate a good server:
• The evil server obtains the certificate for the good server.
• The evil server uses an active network attack to arrange for traffic from a particular browser intended
for the good server to be sent to evil server instead.
• When a client attempts to open an HTTPS connection to the good server, evil server receives
connection open request and behaves just like the good server, returning the good server's certificate
at the appropriate point in the protocol.
Assuming that the evil server can obtain a valid certificate and mount an active network attack, can the
client's security be compromised? Explain your answer.
Answer:
• No, the bad server doesn’t have the good server’s private key, so it will not be able to decrypt the
client’s message.
HTTP is used by browsers to transfer information encoded in HTML. Browsers also can use HTTP to
transfer information not encoded in HTML. Describe different types of information (other than
HTML) regularly fetched using HTTP by browsers running modern web applications. (Note:
question ask about what is transported by the protocol, not what is in the protocol headers.)
Answer:
▪ Xml is also used to transfer information with http (XML is a markup language where
documents must be marked up correctly)
2. What does it mean to the user of a web applications if the browser shows an extended certificate such
as: (& Question Model 3 Q.2.3)
Answer:
• Most lower-authentication certificates require only that you prove
▪ Ownership of the domain (DV SSL)
▪ Or validate your identity at an organizational level (OV SSL).
• Extended certificate (EV SSL) certificates add additional validation steps and offer the highest
level of authentication to safeguard your brand and protect your users.
Question 4:
-------------------------------------------------------- Transaction 1 --------------------------------------------------------
https://www.piazza.com/
GET / HTTP/1.1
Host: www.piazza.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip,
Cookie:piazza_session=EGyCDvHvKwuwCyLDEDGGtxGyFuHDEFGx.0;
__utma=231435806.1547084154.1357668061.1361132434.1361506957.15;
__utmz=231435806.1357668061.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=231435806.|2=user_type=instructor=1
Connection: keep-alive
What is the web server involved in these HTTP transactions? → Answer: Nginx
1. What is the name and version of the browser used in these transactions? → Answer: Firefox/19.0
2. Are any transactions returning compressed data? Specify what type of files transmitted:
Answer:
Content-Type: text/html
Content-Type: application/x-JavaScript
3. What data is returned by the browser in transaction 2 and why? → Nothing because the statues 304 not
modified
4. Transaction 1 returns “302 Found”. What does that mean? → Html page because type of content text/html
5. Name 3 headers used in these transactions for cache control
Answer:
Cache-Control: public, max-age=124
Cache-Control: no-cache
Additional Questions from the Book
Class Work 1:
Class Work 2:
13. Consider the following HTTP transaction:
4. Using RUBY, re-write the function for displaying odd numbers in question
Question 1:
Write about each:
• MIME, SMTP, POP3
MIME:
• Reliable delivery across wide largest range of environments.
• Content transfer encoding field
o Six values
o Three (7bit, 8bit, binary) no encoding done→ Provide info about nature of data.
• X-token
• Named nonstandard encoding
• Base 64
STMP:
• STMP uses persistent connection
• STMP requires that message (header &body) be in 7-bit ASCII.
• Certain character strings are not permitted in message (e.g. CRLF.CRLF) thus message has to be
encoded (usually into either base 64 or quoted printable)
• STMP server uses CRLF.CRLF to determine end of message.
STMP:
• Emails are stored on a single device.
• Sent emails are stored in a single device.
• Emails can be accessed from a single device
Model 3:
Question 1:
Q1) Indicate whether each of the following statement is True or False and explain your answer briefly.
a) In HTML entities are used to incorporate external content into a Web page, such as images.
Answer: False, entities are used to display Reserved characters in HTML, such as “<” and “>”.
e.g. → To display a less than sign (<) we must write: < (< is the HTML entity)
b) A single partial-page template in rails can be used in more than one Web Page.
Answer: True, a partial can be rendered any number of times, either within the same page, or in
different pages.
c) When a user places an order via the web and posts the final “Confirm” form for the purchase, the
web server should normally return HTML for the order confirmation page in the response for the
HTTP request.
Answer: False, the normal response to a form post should be to redirect the browser, so that the
post-action does not appear in the browser’s history list.
d) Suppose that an online retailer uses a relational database to keep track if orders, and one table
contains a row for each order. If an order contains several items, the foreign keys for each of those
items would typically be stored in the row for that order.
Answer: False, A row in a database cannot contain a variable number of items; thus, a separate join
table should be used to keep track of the items in orders.
e) In a scripting language types are typically associated with values, not variables. (+quiz 2020)
Answer: True, Variables are typically not declared in scripting language is, so there is no
opportunity to assign them a type
f) Web browsers are stateless: if a browser isn’t displaying a page for a particular server it need not
retain any state related to that server. (+quiz 2020)
Answer: False, Web servers are stateless, not browsers. In particular, a browser must retain cookies,
which store state related to particular servers.
Question 3:
Question 4:
Given the URL → http://web.stanford.edu/class/cs142/exams.html?v=win1617#midterm
A. Fill in the blanks:
B. Without using a full URL, complete the HTML snippets below, making sure to write the shortest
possible link to get the URL above if:
• The browser is currently at http://web.stanford.edu/class
<a href="./cs142/exams.html"> Link A</a>
• It is by far the most common tool for designing Web pages, which is why people usually refer to
HTML as the backbone of the WWW.
• Thanks to HTML structuring elements (tags), text documents interpreted by browsers can display
their contents according to specified formats. HTML is one of the main reasons why the Web has
become so popular over the years.
Q2) Explain Site development process (OR) Mention briefly website development process (quiz 2020)
Answer:
.
Midterm 2021 – 2022
Question 1:
1. Web Applications are revolutionary compared to traditional application. Discuss.
2. Explain What are the main function of Domain Names? Mention the Top-Level Domains.
3. Write about Each: MIME, SMTP, POP3
4. Web servers are stateless, not browsers. Discuss.
5. What does the web server typically do with the following html fragment?
<a href="#top">Top</a>
Question 2:
A. Consider the following HTML code:
<!DOCTYPE html>
<html>
<head> </head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph</p>
<p>This is a another paragraph.</p>
</body>
</html>
1. What is CSS? What are the advantages of using an external CSS file in Web Pages?
2. Add an external style sheet with the URL: “mystle.css”
3. Set “background-color:linen” for the page, using an internal style sheet.
4. Set “background-color:yellow” for the page, using an inline style.
B. Write HTML code to create REGISTERATION FORM for a subscription in spot club, including
all important items using different HTML elements as possible. Sketch your code output form.
Final 2021 – 2022
Question 1:
I. Sharing accurate information was considered as a key to socially fight covid pandemic lies. Write
down steps for fast designing “Corona Virus Awareness web site”. Showing steps, concepts you
may follow, ideas may be utilized and tools roles [5 marks].
II. Write JavaScript function to find the highest value in a list of numbers passed as parameters to
function FindMax. Use argument object to write your code. [5 marks]
III. Write the HTML5 code to add video element to your webpage. Write the functions script required to
use video built-in controls (play, pause, seek), add controls for display size (Big, Small, Normal).
[5 marks].
Question 2:
I. Answer in short sentences [10 marks]
1. Explain the packet switching with TCP/IP.
2. Explain the syntax of a uniform resource locator. Show some security considerations to URL.
3. Draw a figure explaining Client / MVC web application.
4. What are the components of the email? Briefly explain the basic functions of the mail user agent.
5. Cloud computing platforms work well for web application startup companies.
II. An attacker can exploit broken authentication and session management functions to impersonate a
user, the attacker only needs to acquire knowledge of a user’s session cookie ID. This information
can be revealed to an attacker in several ways. Discuss. [3 marks]
III. A web application receives a HTTP response header from an HTTP GET request that contains the
following line: [2 marks]
Cache-Control: max-age=2628000
1. Describe benefit a web application would get from having that line in a HTTP GET response
header. Give an example of a HTTP GET request done by your website that it would be
appropriate to apply this line.
2. Describe the disadvantage of having this line on a HTTP GET response. Given an example of a
HTTP GET response done by your website that it would be inappropriate?
Question 3:
I. Write the HTML code to generate the following table: [3 marks]
Beta
Tilde Lambda
Gamma
Alpha 1 2 3 4
Delta Theta
Zeta
Omega Kappa
II. Write a style sheet that expresses that H1 and H2 should always be centered and always be red. Add
a rule for a class bGreen that define text in bold and green. [2 marks]
III. Write the HTML code that replaces the BODY section to generate the following frames: top 100
pixels for a header head.html, a bottom frame with left 200 pixels for a menu in menu.html and the
remainder containing main.html. [2 marks]
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Iframe</title>
<style>
* { margin: 0; }
body,html { height: 100%; }
iframe { border: none; }
.grid {
display: grid;
grid-template-areas:
'header header'
'menu main';
grid-template-rows: 100px 1fr;
grid-template-columns: 200px 1fr;
}
.header { grid-area: header; }
.menu { grid-area: menu; }
.main { grid-area: main; }
</style>
</head>
<body class="grid">
<div class="header">
<iframe src="./head.html" height="100%" width="100%"></iframe>
</div>
<div class="menu">
<iframe src="./menu.html" height="100%" width="100%"></iframe>
</div>
<div class="main">
<iframe src="./main.html" height="100%" width="100%"></iframe>
</div>
</body>
</html>
Head.html
<!DOCTYPE html>
<html lang="en">
<body style="background-color: skyblue">
<h1>header</h1>
</body>
</html>
<hr />
Subtotal: $ <input type="text" name="stot" /><br />
<hr />
Tax7%: $ <input type="text" name="tax" /><br />
<hr />
Total: $ <input type="text" name="tot" /><br />
<hr />
<input type="submit" value="Submit Query" />
<input type="reset" />
</form>
1. Write a JavaScript function and indicate the changes in the form such that only digits and “.” Are
allowed when entering “first”, “second”, and “third” and when the value is correct the
corresponding checkbox is selected. [3 marks]
2. Write a JavaScript function and indicate the changes in the form such that when a checkbox is
unselected the corresponding value is reset to 0. [3 marks]
3. Adjust your JavaScript code such that the subtotal, the tax and the total are calculated whenever a
value is changed [2 marks]
V. Write the code to display a form along with JavaScript as shown below. User should be able to select
a picture after clicking on browse button and when he presses “click” button, the picture should be
displayed.
Next the user should be able to enter value of image height and width and when he presses “apply”
button, the size of picture should change as shown: [5 marks]
Answer
Index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script defer src="./app.js"></script>
<style>
.img-container {
width: 500px;
height: 500px;
}
</style>
</head>
<body>
<form name="f1">
<div>
<label for="originalImgInput"> Select the image that you want to display </label>
<br />
<input id="originalImgInput" type="file" />
</div>
<div class="img-container">
<img id="originalImgPreview" name="originalImgPreview" />
</div>
<div>
<label for="height">specify the new height</label>
<input id="height" type="number" />
</div>
<div>
<label for="width">specify the new width</label>
<input id="width" type="number" />
</div>
<button id="apply">apply</button>
</form>
</body>
</html>
app.js
const originalImgInput = document.querySelector('#originalImgInput')
const originalImg = document.querySelector('#originalImgPreview')
const height = document.querySelector('#height')
const width = document.querySelector('#width')
const resizeBtn = document.querySelector('#apply')
function createImgPreview() {
const file = originalImgInput.files[0]
if (file) {
const reader = new FileReader()
reader. () {
originalImg.src = reader.result
}
reader.readAsDataURL(file)
}
}
originalImgInput.addEventListener('change', createImgPreview)