Web Application Programming (resit) PDF

Title Web Application Programming (resit)
Author Diego Muñoz González
Course Databases and Information Retrieval
Institution University of Essex
Pages 5
File Size 192.8 KB
File Type PDF
Total Downloads 103
Total Views 141

Summary

resit web application programming all slides...


Description

ANSWER SHEET (please use as man manyy sheets aass you need to)

Please enter your Registration number here:

1

9

0

0

2

1

0

TYPE THE QUESTION NUMBER AND YOUR ANSWERS HERE:

Question 1 a) DOM and W3C DOM are two types of document object model legacy and their function priorly is to implement Javascript for web application programming elements of the HTML page. The DOM legacy has inconsistent naming conventions so it is awkward to use but anyway is still more concise than the W3C. The W3C DOM has consistent naming conventions, so it is simpler to use but requires more code to write. b) - Implicit type conversion: While javascript allows you to implicitly convert types when executing arithmetic operations, conditional statements and loops, java doesn’t. For example, if you try to evaluate a string as an if condition, javascript will automatically convert that string to boolean and try to evaluate the expression, passing an error silently and warning you, whereas Java will throw a type exception.

- Higher-order functions: A higher order function is a function that either takes a function as an argument or that returns a function. Javascript is built upon this functionality and is able to handle functions as arguments and return them. On the other hand, Java does not permit the user to pass functions as argument neither return them. - Arrays and associative arrays: While Java does support both arrays and associative arrays ( hashes ) and provides methods and functionality to handle these types, javascript does not support arrays with named indexes as Java does with hashes. In javascript all arrays are numbered indexed. c)

One way to invoke JavaScript in an HTML page when is loaded is by using the onload attribute of the body:

window.onload = function() { myfunction(param); };

Another way of invoking JavaScript code to an HTML page is by using a hyperlink; in this case, the user should click on the link to invoke it.

Once complete, please submit your answers to FASER: http://faser.essex.ac.uk/

Question 2 a) // Load number values from input fields to variables va varr n1 = $('#id1').val(); va varr n2 = $('#id2').val(); va varr n3 = $('#id3').val(); va varr n4 = $('#id4').val(); // Load the presentation reference to later replace html va varr presentation = $('#sorted'); // Build the unordered array va varr array = [n1,n2,n3,n4]; // Sort the array ascending array.sort( (a,b) => a - b ); // Display the ordered array inside the presentation tag presentation.html(array); b) In the example given, the code is not managing a deadlock scenario, neither restricting simultaneous access to shared resources so that atomic operations can be performed on one-to-one basis. In this case, the atomic operation consists of the update of a global variable. If we’d look into assembler code we’d notice that the update operation turns into three separate system calls. The first call will retrieve the current value of the variable from the register. The second call will perform the mathematical operation of incrementing the variable by 1, that's a sum. And finally the third system call will save the updated value into the register, making the atomic operation finished. Now, as we’re not managing atomic operations, it’s possible that a thread is put to sleep by the operative system just between system calls 1 and 2, while another thread executes and runs the atomic operation. When the slept thread resumes will update the variable with an old value that he had read before the last thread updated the value, so the resulting increment value would be wrong.

In order to solve this issue, the code should make the increment operation immutable as a transaction so that the operative system is told to never stop the thread executing while the transaction is being executed, allowing the system to successfully execute the variable increment in a concurrent implementation. This will cause other threads being held to execute it’s atomic operation while a thread is performing this operation.

c)

Basket

You have items in your basket for a total cost of ${basket.getTotalCost()} See below the details for each product Name

Once complete, please submit your answers to FASER: http://faser.essex.ac.uk/

Quantity Price

${entry.key.name} ${entry.key.price} ${entry.value}



Question 3 (a)

Once complete, please submit your answers to FASER: http://faser.essex.ac.uk/

(b) XML documents have some requirements so that they are well-formed. They require content to be defined, content to be delimited with a beginning and end tag and that the content is properly nested; parents within roots and children within parents. For an XML document to be well-formed, some rules are established about the declaration and treatment of entities. The main thing in XML documents are the tags. The tags can only contain encoded legal unicode characters. Since the tags are enclosed between chevrons , it’s not permitted to use those except for performing their markup-delineation roles. The tags are casesensitive. The beginning and end of tags must match exactly. (c)

HP Pavilion Laptotp 1200 $

Hewlett Packward California, Palo Alto, USA



Question 4 (a.i) public class Book Book{ protected String name; protected in intt cost; protected List authors; Book(name,cost,authors){ static void Book thi thiss.name = name; thi thiss.cost = cost; thi thiss.authors = authors; } getName(){ public String getName ret retur ur urn n this.name; } getCost(){ public in intt getCost retu return rn this.cost; } getAuthor(){ public Author getAuthor retu return rn this.author; } } Once complete, please submit your answers to FASER: http://faser.essex.ac.uk/

interface DA DAO O{ findAllBooks Books Books(); List findAll List findBook findBooksByAuthor sByAuthor sByAuthor(); findAllAuthors AllAuthors AllAuthors(); List find List find findAuthorsByBook AuthorsByBook AuthorsByBook(); }

(a.ii)











(b) To make the same JSP file display both all books and books by a particular author, we would have to change the way the JSP file iterates through the books list. If, in the requested url there's a parameter called author, the jsp should filter the books list by author and then start to iterate and render those books only. If in the requested url there’s no author parameter, then the jsp file would just render all the books since there’s no author specified. For instance, the urls could be : 1. https://mysite/books : In this url, the jsp file will render all books in the system. 2. https://mysite/books?author=1 : In this url, if an author with id 1 exists in the system, the jsp file will render all the books having author with id 1.

Once complete, please submit your answers to FASER: http://faser.essex.ac.uk/...


Similar Free PDFs