1/8

Web Applications

Mobile Web Applications

Prof. Dr. Ansgar Gerlicher and Dr. Thomas Fankhauser

2/8

Architecture for Web Sites

center 100%

3/8

Architecture for Web Applications

center 100%

4/8

HTTP Protocol

Request

GET / HTTP/1.1
Host: www.hdm-stuttgart.de

Response

HTTP/1.1 302 Found
Date: Tue, 05 Sep 2017 12:32:40 GMT
Server: Apache
Location: https://www.hdm-stuttgart.de/
Content-Length: 213
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://www.hdm-stuttgart.de/">here</a>.</p>
</body></html>

Example: HTTP via Telnet

telnet www.hdm-stuttgart.de 80
Trying 141.62.1.59...
Connected to www.hdm-stuttgart.de.
Escape character is '^]'.
GET / HTTP/1.1
Host: www.hdm-stuttgart.de

HTTP/1.1 302 Found
Date: Tue, 05 Sep 2017 12:32:40 GMT
Server: Apache
Location: https://www.hdm-stuttgart.de/
Content-Length: 213
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="https://www.hdm-stuttgart.de/">here</a>.</p>
</body></html>
Connection closed by foreign host.
5/8

REST: Representational State Transfer

Resource GET PUT PATCH POST DELETE
http://api.example.com/users List all users Replace all users - Create a new user Delete all users
http://api.example.com/users/5 Retrieve user 5 Replace or create user 5 Update user 5 - Delete user 5

Resource can also be nested, e.g. http://api.example.com/users/5/messages is the collection of messages for user 5

Example APIs

6/8

DOM: Document Object Model

Select Elements

> document.querySelectorAll("h1")
(1) [h1]

> document.querySelectorAll("h2")
(18) [h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2, h2]

Remove Elements

> document.querySelector("h1").remove();

Create and Add Elements

> var e = document.createElement("h1")
undefined

> document.body.prepend(e)
undefined

> e.innerText = "hello"
"hello"

Change Styling

> document.querySelector("h2").style.color = "blue";
undefined
> document.querySelector("h2").classList.add("blue");
undefined
> document.querySelector("h2").classList.remove("blue");
undefined
7/8

Frameworks

8/8

Deployment

Services, Containers, Docker