Web-Based Computing 1 Flashcards
What is the chief advantage and disadvantage of using the web for building a distributed application?
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
What does HTML stand for? What role does HTML play in a web based distributed system?
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.
What does HTTP stand for? Comment briefly on the suitability of HTTP as a platform for creating distributed applications.
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
What does it mean to say that HTTP is a request response protocol? What (in general) goes into a request and a response?

What is MIME? How is MIME used in HTTP?
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.
Explain, in general terms, how user input is captured in a web application and how it is delivered to the web server.
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 do the web client (browser) and server cooperate to enable the generation of *user-specific* HTML?
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)
What extra work is required to make an RMI server multi-threaded?
- 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.
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.
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.
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?
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
Describe three general features offered by server-side scripting languages that make them useful.
- 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
What is the primary benefit of embedding server-side script code in HTML instead of write server side script code that explicitly prints HTML?
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
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, …)
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.
Give examples of data you might want to store per application and per session using ASPs/JSPs/PHP
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.
What are the server-side components of a web-application?
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 can server-side information be shared between web pages? (e.g. using PHP)
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
Web servers are, almost always, multi-threaded. How does this affect the development of server-side scripts? What must be coded and when?
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
What is a cookie? How can cookies be used to support stateful web applications?
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.
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.
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.
What is CSS and what capability does it provide? Why is it better to separate CSS and HTML code?
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
Give two examples of some processing that is well suited to the client side.
Veryifying user input
…
User interaction with the page, animations
Presentation of HTML
Execution of client side scripts
What is the general form of a jQuery statement? What does each of the two parts specify?
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)
Give 3 examples of ways in which a jQuery statement may select elements to operate on.
- $(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
What does AJAX stand for and what, generally, does it enable?
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
