Web-Based Computing 1 Flashcards

1
Q

What is the chief advantage and disadvantage of using the web for building a distributed application?

A

Pros:

  • Anyone can use the application on any device with a broswer
  • Computing system are fairly heavy server oriented

Cons:

  • There are limits in the HTTP protocol since the we was designed to distribute info
  • Limited application functionality (heavy interaction and controver over display issues
    • This functionality often relys on servers which can slow down the application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does HTML stand for? What role does HTML play in a web ­based distributed system?

A

HTML = Hypertext Markup Language

Text files with embedded “markup” (commands/directives) that add meaning to the text and containing “hyperlinks” used to refer to other document.

HTML tags specify how the information in each document should be presented (generally), how the document itself is structured, and what other documents are linked to the document.

HTML is the backbone of the structure and presentation of a web-app for the client. Dynamic generation of HTML allows for customization and interaction with the user and acts as the “UI”/display to the user.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does HTTP stand for? Comment briefly on the suitability of HTTP as a platform for creating distributed applications.

A

HTTP = Hypertext Transfer Protocol

HTTP was originally indented to provide access-to and display of distributed hyper-linked files.

HTTP limits what can be done easily with distributed applications.

There is a security concern (which led to HTTPS, which would be a preferred protocol) and the request-response protocol is particular combersome/wooden, which requires one to think about design of apps in a different way than most people are familiar with.

However, it allows anyone with a browser to essetially use our application

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does it mean to say that HTTP is a request­ response protocol? What (in general) goes into a request and a response?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is MIME? How is MIME used in HTTP?

A

Multi-purpose Internet Mail Extensions

MIME is used to describe the content type in the ‘Content-Type’ header in an HTTP message (such as text/html or image/jpeg). Which specifies the type of data encoded in the mail message or HTTP body.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Explain, in general terms, how user input is captured in a web application and how it is delivered to the web server.

A

User input is captured through HTML forms and is sent through a HTTP protocol request to the server using GET or POST.

The webserver then extracts the data from the HTTP GET/POST request

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do the web client (browser) and server cooperate to enable the generation of *user-specific* HTML?

A

The server accepts GET/POST request via stream sockets and execute code specific to the web app using data from the client to dynamically generate HTML and return it and close the connection.

Using some sort of server side scripting language (PHP)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What extra work is required to make an RMI server multi-threaded?

A
  • The server binds an object from the server into the Registry.
  • Several clients can get a reference to the remote object from the RMI Registry.
  • Multiple threads will be started/used by the RMI runtime upon concurrent call of a method on the remote object.

RMI is multithreaded. Two clients can and will execute methods on the remote object simultaneously. Synchronization must be used to prevent incorrect use of shared variables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

It is certainly possible to write the server and client code for a distributed application using different languages (e.g. Java server, Python client). Comment briefly on how this is possible and what challenge(s) might arise when doing so.

A

TCP and UDP are universal socket stream protocols.

Some challenges may include performance, reliability, memory management, different string representations.

Data format of the transferred data may also be a challenge.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What advantages are offered by incorporating a facility for downloading client code to a client device *on-demand* when the client begins using a distributed application? Are there any disadvantages?

A

Since the alternative is to install your own client code yourself, some advantages include:

  • Editing and running code
  • Allow complex tasks to be performed in relatively few steps.
  • Minimum programming knowledge or experience required.

Disadvantages can include:

  • Executable code can inadvertently be downloaded from a remote server and run using the local browser’s interpreter.
  • Speed of communication over the network is many orders of magnitude slower than the speed of computation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe three general features offered by server-side scripting languages that make them useful.

A
  • Allows us to embed scripts in HTML.
  • Corresponds to each activity supported by the application by sessions.
  • Allows us to separate the “user interface” (HTML) from the content generation (script code)
    • So you can change the page layout without changing code generating the dynamic content.
    • Allows for:
      • Easier development,
      • faster development and
      • decreased maintenance effort

JSPs provide:

  • A language for developing text-based pages that descripte how to process a request to create an HTML response
  • A means of accessing server-side objects
    • To provide a means of generating dymanic content using information not directly available to the JSP
  • A mechanism for extending the JSP language
    • Important for simplifying repeated tasks and also for the future evolution of JSP technology
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the primary benefit of embedding server-side script code in HTML instead of write server side script code that explicitly prints HTML?

A

It allows you to dynamically print the required HTML given the user’s actions.

Perhaps because it allows you to separate the user interface from content generation (script code).

You can change the page layout without change code generating the dynamic content

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Associative arrays (or collections with keyed lookup) are very useful in writing server side scripts. Give three examples where such structures are commonly applied (e.g. in PHP, JSP, ASP, …)

A

Product names with prices

Phonebook contacts

Library books

Associative arrays are often used in web-based systems where, for example, the values entered on a web form are referenced by the names associated with the form elements (check boxes, radio buttons, text boxes, etc.)

Getting information from session data is also an associative array

As well as HTML forms.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Give examples of data you might want to store per application and per session using ASPs/JSPs/PHP

A

What the user has purchased in a shopping cart

When the user needs to fill in a long form

When the user successfully logins into their account in a web application.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the server-side components of a web-application?

A

Process user input

Display pages

Structure web applications

Interact with permanent storage (SQL, files)

Server: accept HTTP GET requests from clients via a stream socket connection, fetch the specific resource from a locally accessible file system, return it in the HTTP response and then close the socket

connection (i.e. basic “Request/Response”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can server-side information be shared between web pages? (e.g. using PHP)

A

In PHP, we can use a session that can store all of the relevant info that is needed for every page per user session. It associates the correct session data with each HTTP request where some client-side state is needed.

Certainly the code at the web server has to store information that is to be shared across app pages

  • E.g. this could potentially be done using some associative array(s) with PHP or in some collection(s) in the Application object with ASP
  • Or in a backing database if we desire persistencen E.g. an Amazon shopping cart
17
Q

Web servers are, almost always, multi-threaded. How does this affect the development of server-side scripts? What must be coded and when?

A

We need to handle concurrancys and synchronization issues

Further, since web servers are multithreaded, any declared data must be guarded to prevent invalid concurrent access

  • That is, access must be synchronized
  • Unfortunately, this can decrease performance

If we have shared variables, we must have a means of synchronizing access to them

18
Q

What is a cookie? How can cookies be used to support stateful web applications?

A

Cookies are a meants by which per-client information can be maintained over time

  • Note: web servers are stateless so we store data (state) at the client in cookies (Set-Cookie :header)

Cookies can be “retireved” by the server to determine if the client was previously connected and if so, what were they doing (could store a client IP address and time of access)

There are is no constraint on what can be in a cookie which makes them very powerful.

19
Q

Servlets, Applets, etc. run Java code but not in traditional environments. Briefly explain how this may impact how they are used and what they can do. Provide two examples.

A

Servlets and Applets are limited to writing client side code.

Applets could be used with Javascript to verify user input.

  • commonly and sensibly down on the client side

Manipulating user input and providing customized output formatting are examples of simple applications of client-side processing

Since servlets run inside a server and applets (🍎🔪) run inside a browser, neither of these offer a direct interface to a user.

Ex 1: Servlets can communicate more by calling each other’s methods.

Ex 2: Servlets can share data with one another.

20
Q

What is CSS and what capability does it provide? Why is it better to separate CSS and HTML code?

A

CSS = Cascading Style Sheets

CSS allows for additional display/presentation faculties as well as the ability to dynamically manipulate the display characteristics of HTML

It is better to seperate CSS and HTML code because it allows us to make changes on one style sheet instead of manually updating it on all HTML pages.

Quicker, easier and less error prone presentation modifcations

21
Q

Give two examples of some processing that is well suited to the client side.

A

Veryifying user input

User interaction with the page, animations

Presentation of HTML

Execution of client side scripts

22
Q

What is the general form of a jQuery statement? What does each of the two parts specify?

A

Basic syntax is: $(selector).action()

  • A $ sign to define/access jQuery
  • A (selector) to “query (or find)” HTML elements
  • A jQuery action() to be performed on the element(s)
23
Q

Give 3 examples of ways in which a jQuery statement may select elements to operate on.

A
  • $(this).hide() - hides the current element.
  • $(“p”).hide() - hides all

elements.

  • $(“.test”).hide() - hides all elements with class=”test”.
  • $(“#test”).hide() - hides the element with id=”test”.

$(“#test”) - selects by id

$(“.test”) - selects by class

$(“p”) - selects all elements of type

24
Q

What does AJAX stand for and what, generally, does it enable?

A

AJAX = Asynchronous Javascript and XML

It uses a combination of:

  • A browers built-in XMLHttpRequest object (to request data from a web seter)
  • JavaScript and HTML DOM (to display or use data)

It allows for the aiblity to:

  • Update a web page without reloading the page
  • Request data from a server - after the page has loaded
  • Recieve data from a server - after the page has loaded
  • Send data to a server - in the background

Ajax limited the need to jump to and load various pages, giving a web app a more “natural” feel

25
What is an application framework? What benefit does the use of a framework provide? What two key things does a framework specify?
The goal of a framework is to simplify the design of complex apps via higher level **reuse**. A framework defines a reusable software architectural design typically composed of: * A group of abstract classes (i.e. parts) * And specification of how their instances collaborate (including **communication**) It is a reusable design for all or, commonly, part of a software system * E.g. a user interface (UI) framework provides a design for just the user interface parts of the system Frameworks specify a context for the components that make up an application and can be applied to any sort of application development.
26
What is a design pattern? What is the MVC pattern? What are its components?
MVC = Model-View-Controller * The Model - defines the underlying data and [“business”] logic that manipulates it * The View - which defines the view (i.e. the user interface) that the user sees * The Controller - coordinates operations between the other system components Design patterns describe reusable software techniques/”idioms” * Strategies for solving specific software problems that we commonly use repeatedly * There are a multitude of well-defined design patterns
27
What is XML used for? What benefits does it provide over other, simpler systems such as ASN.1?
XML = eXtensible Markup Language A markup language that adds meta-information (information about information) to a document (like HTML). XML is focused on document content description NOT about presentation. XML enables effective data structuring and simplified data exchange * You can define your own data “types” (unlike HTML) XML is important for standardization, support for structure data and self description. How XML is used is a matter for the software (XML-aware app) processing the XML documents.
28
What is the difference between a well-formed and a valid XML document?
Well-formed = An XML document that is syntactically correct Valid = Valid means the XML document conforms to the specification in the DTD (Document Type Definition) or XML schema definition (XSD).
29
What is a DTD? How is it related to an XML document? How is it related to an XML-aware application?
A DTD describes the structure of a particular type of XML file. * It is a reference when creating XML files that are expected to meet a type of definition * It is used by an XML-aware application that wishes to process such file to know what it should expect * It enumerates all the possible tags in a given XML specification and specifies how they can be used (nesting rules) * In essence it describes the proper use of tags and thereby the valid hierarchical structure of the corresponding documents
30
What is the root element in an XML specification? Why must there be only a single root element?
The root element is the tag that encompasses all other tags in an XML document. All tags in XML MUST have matching closing tags and tags MUST be properly nested, therefore there must be one tag (the root tag) that encompasses all other tags.
31
What is XSL? How is it related to XML? What is XSL used for?
XSL = eXtensible Stylesheet Language It is a stylesheet language used specifically to display an XML document. Very similar to how CSS is used with HTML to associate presentation characteristics with data tags Short for Extensible Style Language, a specification for separating style from content when creating HTML or XML pages. The specifications work much like templates, allowing designers to apply single style documents to multiple pages. XSL is the second style specification to be offered by the World Wide Web Consortium (W3C )(www.w3c.org). The first, called Cascading Style Sheets(CSS), is similar to XSL but does not include two major XSL's innovations -- allowing developers to dictate the way Web pages are printed, and specifications allowing one to transfer XML documents across different applications. W3C released the first draft of XSL in August 1998, and promotes the specifications as helpful to the Web's speed, accessibility, and maintenance.
32
In many early peer-to-peer distributed applications, there was often a centralized server used to provide information about what various peers have to offer. Speculate on how this could be avoided and how expensive, convenient, scalable, etc. your alternative approach would be.
One centralized server, maybe we could use a bit of DNS round robin style... Maybe all the clients could keep the information Maybe we bould broadcast across the network
33
What is flooding? What is the chief advantage and chief disadvantage of using flooding algorithms?
Flooding is asking all machines on the network for a resource (used in broadcast). Often restricted to LANS. When broadcasting a request on the local network the resource provider(s) that recieve the request can respond. Advantages: * If a packet can be delivered, it will (probably mult times) * Since flooding naturally utilizes every path through a network, it will also use the shortest path * Simple to implement Disadvantages * Costly in wasted bandwidth (and DNS attacks use this to slow down a network) * Messages can become duplicated and further slow the network * Duplicates may circulate forevery (unless addressed in code
34
What is a gossip protocol? Why is it preferable to flooding?
Why gossip vs flooding: Flooding can slow down an entire network. Gossip shares information in an exponential way, where instead of sending the same message to every machine at once, information is shared to one machine who shares that information with others and grows in that manner. It has less potential slow down the entire network (imagine if all machines where flooding at the same time). **Flooding:** simple routing technique in computer networks where a source or node sends packets through every outgoing link. This is often used as a denial of service attack by flooding network traffic. This is not something that is typically done on a WAN due to it's ability to slow down a network. **Gossip:** A gossip protocol is a procedure or process of computer peer-to-peer communication that is based on the way that epidemics spread. Some distributed systems use peer-to-peer gossip to ensure that data is routed to all members of an ad-hoc network. Some ad-hoc networks have no central registry and the only way to spread common data is to rely on each member to pass it along to their neighbors. The term epidemic protocol is sometimes used as a synonym for a gossip protocol, because gossip spreads information in a manner similar to the spread of a virusin a biological community. Suppose that we want to find the object that most closely matches some search pattern, within a network of unknown size, but where the computers are linked to one another and where each machine is running a small agent program that implements a gossip protocol. To start the search, a user would ask the local agent to begin to gossip about the search string. (We're assuming that agents either start with a known list of peers, or retrieve this information from some kind of a shared store.) Periodically, at some rate (let's say ten times per second, for simplicity), each agent picks some other agent at random, and gossips with it. Search strings known to A will now also be known to B, and vice versa. In the next "round" of gossip A and B will pick additional random peers, maybe C and D. This round-by-round doubling phenomenon makes the protocol very robust, even if some messages get lost, or some of the selected peers are the same or already know about the search string. On receipt of a search string for the first time, each agent checks its local machine for matching documents. Agents also gossip about the best match, to date. Thus, if A gossips with B, after the interaction, A will know of the best matches known to B, and vice versa. Best matches will "spread" through the network.
35
What is a DHT? In what ways is it useful in building P2P applications?
DHT = Distributed Hash Table A DHT gives you a dictionary-like interface, but the nodes are distributed across the network. The trick with DHTs is that the node that gets to store a particular key is found by hashing that key, so in effect your hash-table buckets are now independent nodes in a network. This gives a lot of fault-tolerance and reliability, and possibly some performance benefit. Responsibility for maintaining the mapping from keys to values is distributed among the nodes, in such a way that a change in the set of participants causes a minimal amount of disruption. This allows a DHT to scale to extremely large numbers of nodes and to handle continual node arrivals, departures, and failures. DHTs form an infrastructure that can be used to build more complex services, such as anycast, cooperative Web caching, distributed file systems, domain name services, instant messaging, multicast, and also peer-to-peer file sharing and content distribution systems. Notable distributed networks that use DHTs include BitTorrent's distributed tracker, the Coral Content Distribution Network, the Kad network, the Storm botnet, the Tox instant messenger, Freenet, the YaCy search engine, and the InterPlanetary File System.
36
What is meant by ORM? How is this related to use in MVC frameworks?
The M in MVC is the data model layer. The data model layer can be whatever you want it to be (assuming it still conforms to the rules of modeling the data and not the business or view), but most people end up using an ORM to model their data. Object-relational mapping (ORM) is a mechanism that makes it possible to address, access and manipulate objects without having to consider how those objects relate to their data sources. ORM lets programmers maintain a consistent view of objects over time, even as the sources that deliver them, the sinks that receive them and the applications that access them change. Based on abstraction, ORM manages the mapping details between a set of objects and underlying relational databases, XML repositories or other data sources and sinks, while simultaneously hiding the often changing details of related interfaces from developers and the code they create. ORM hides and encapsulates change in the data source itself, so that when data sources or their APIs change, only ORM needs to change to keep up—not the applications that use ORM to insulate themselves from this kind of effort. This capacity lets developers take advantage of new classes as they become available and also makes it easy to extend ORM-based applications. In many cases, ORM changes can incorporate new technology and capability without requiring changes to the code for related applications.
37
Briefly compare and contrast JSON and XML. When might you choose to use JSON instead of XML and why?
In short: JSON is typically smaller, faster and easier than XML and is probably preferable for most applications moving object-based data JSON is Like XML Because * Both JSON and XML are "self describing" (human readable) * Both JSON and XML are hierarchical (values within values) * Both JSON and XML can be parsed and used by lots of programming languages * Both JSON and XML can be fetched with an XMLHttpRequest JSON is Unlike XML Because * JSON doesn't use end tag * JSON is shorter * JSON is quicker to read and write * JSON can use arrays The biggest difference is: XML has to be parsed with an XML parser. JSON can be parsed by a standard JavaScript function. Why JSON is Better Than XML * XML is much more difficult to parse than JSON. * JSON is parsed into a ready-to-use JavaScript object. * For AJAX applications, JSON is faster and easier than XML: * Using XML * Fetch an XML document * Use the XML DOM to loop through the document * Extract values and store in variables * Using JSON * Fetch a JSON string * JSON.Parse the JSON string
38
Give an example of a JSON specification where the object described contains another object. How is this nesting specified in the JSON?
It's object data-type. In the instance data model JSON has six primitive data types, Objects being one of them. You can access nested JSON objects by using the dot notation or bracket notation: ``` x = myObj.cars.car2; // or: x = myObj.cars["car2"]; ```