Académique Documents
Professionnel Documents
Culture Documents
Most of these exercises are meant to be answered in text, so write down your replies so you will
remember.
1. What is your public IP address right now, and how did you find it?
www.whatismyip.com -> 91.100.103.58 / 5.179.80.204
2. What is your private IP address right now (do this both at home and in school), and who/what gave
you that address?
command konsol – ipconfig – find ivp4: 10.50.137.120
Local Home ip: 192.168.1.2
Routeren dedikerede computeren en IP adresse.
3. What’s special about these address ranges?
10.0.0.0 – 10.255.255.255 – 16 millioner addresser 24 bit
172.16.0.0 – 172.31.255.255 - 1 million 20 bit – loopback adressen
92.168.0.0 – 192.168.255.255 – 65000 16 bit
4. What’s special about this ip-address: 127.0.0.1? adresse som reffererer til den computer
man sidder ved. localhost
5. What kind of service would you expect to find on a server using these ports: 22, 23, 25, 53,
80, 443? Ssh, telnet, SMTP, DNS, HTTP, HTTPS
6. What is the IP address of studypoints.dk and how did you find it?
Ipinfo.info -> 176.9.147.60
7. If you write https://studypoints.dk in your browser, how did “it” figure out that it should go
to the IP address you discovered above?
Computeren bruger en DNS server for at slå det domain op man prøver forbinde adgang til.
Det kaldes DNS name resolution og DNS serveren resolver domainet til en IP adresse.
8. Explain shortly the purpose of an ip-address and a port-number and why we need both
Alle enheder som er forbundet til et netværk har en numerisk label tilknyttet som bruges til
enten at hoste eller netværk interface identifikation og adresse lokation.
Porte er interfaces mellem to computere eller enheder som er forbundet.
9. What is your (nearest) DNS server,?
10. 192.168.1.1 SYS
11. What is (conceptually) the DNS system and the purpose with a DNS Server? DNS system: DNS
server er placeret på et IP baseret datanet og oversætter alle domains til IP adresser. DNS server kan enten
oversætte mellem ip adresser og domænenavne, eller kontakte andre servere for at få en adresse oversat.
12. What is your current Gateway, and how did you find it?
Netværksinstillinger - > 192.168.1.1
13. What is the address of your current DHCP-Server, and how did you find it?
Netværksinstillinger -> 192.168.1.1
14. Explain (conceptually) about the TCP/IP-protocol stack
Videregivelse af data på et netværk bliver udført i lag, hvor hver protocol i hvert lag gør
noget samtidig med de andre lag. De lag kaldes protocol stack. TCP er transport lag og ip er
netværkslaget.
15. Explain about the HTTP Protocol (the following exercises will go much deeper into this
protocol) Http er en asymetrisk request – response clientserver protocol. En HTTP client sender et request
tile n HTTP server hvorefter serveren sender et response tilbage til clienten. Også kaldet en pull protocol.
16. Explain (conceptually) how HTTP and TCP/IP are connected (what can HTTP do, and where
does it fit into TCP/IP)
HTTP er standard applikations protokollen oven på TCP/IP som håndterer web browser
requests og responses. Browsers og serverer kommunikerer via TCP/IP protokoller.
Press the run button. When the file is shown in the browser (Chrome), open the network tab in the
developer window (Ctrl-shift-j) and press F5
Observe and explain each of the values monitored (use view source to see the plain messages).
Hints: In order to better observe the values related to Caching you might need to:
Go back to your browser and (while the developer window is open) change the url to point to the new file.
Add an external style sheet to the page (<link rel="stylesheet" type="text/css" href="myStyle.css">)
Reload the page again, observe the request(s) being made, and explain the purpose of the Connection:
header.
Vi beder nu om at få et request på det billede vi har indsat og stylesheet. Der sendes nu 5 pakker i
alt.
Connection header viser os status på den request vores computer sender til serveren, samt det response
der sendes som pakker tilbage.
Remove the processRequest and the doPost method completely from the generated servlet-code.
In the doGet(..) method replace the call to processRequest with this line:
response.sendRedirect("r.html");
While your server is running, open a (Chrome) browser, and in this, open Chrome Developer Tools and the
network tab.
Enter the address for the servlet (http:localhost:8080/redirect) into the browser and explain:
Computeren sender en request via browseren (url’en http), og metoden GET til serveren. I vores
servlet håndterer doGet() metoden hvor vi sendes hen som redirecter os til r.html når vi indtaster
url’en http://localhost:8080/WebApplication1/redirect.
In Google Chrome enter this address (with the developer window + the network-tab open), and exactly as
it is spelled):
http://studypoints.dk:
Explain the first two request monitored (notice where you requested to go, and where you actually ended).
Important: Later this week, you will learn how to setup your own server to use https, and ONLY https.
Den ene studypoints.dk request har en General header som via metoden GET laver et internal redirect
(code 307) til response header med lokation studypoints.dk. Forskellen ligger i den først requester http og
derefter kommer med response til HTTPS.
In the processRequest(..) method, just before the try-statement add this code:
While your server is running, open open Chrome developer tools and the network tab and call the servlet.
Write down the response code generated by the server as for the previous exercises
1. Request URL:
http://localhost:8080/WebApplication1/ups
2. Request Method:
GET
3. Status Code:
4. Remote Address:
[::1]:8080
5. Referrer Policy:
no-referrer-when-downgrade
Write down the response code generated by the server as for the previous exercises
1. Request URL:
http://localhost:8080/i_dont_exist
2. Request Method:
GET
3. Status Code:
4. Remote Address:
[::1]:8080
5. Referrer Policy:
no-referrer-when-downgrade
Your document, containing the Status Codes for all the exercises done so far, should now contain codes like
2xx, 3xx, 4xx and 5xx.
Explain (write down your answer so you won’t forget) the meaning of the first digit in the 3-digit Status
Codes you have seen so far.
200: Et request sendes til servletten og response gives tilbage om et succesfuldt url svar.
302: opstår når der sker en url redirection. Dvs den url man requester giver et redirect (response) til en
anden url.
404: et standart http svar (response) om at serveren ikke kan finde den url der blive requested.
500: der er en fejl på website’s server (internal error) og den kan ikke informere om hvad der gik galt.
This information is available to a servlet (is available to any web-server technology) via the request object.
Create a Servlet, which should output this information in a table as sketched in this figure (or in any way
you like, but don’t focus on presentation).
SVAR: http://localhost:8080/WebApplication1/getHeader
5) Get/Post-parameters
Create a new html-file in the web-project made in exercise 1.
Add a form to the file, including two text input boxes and a submit button as sketched below:
Add an extra input field to the form with type=”hidden”, name=”hidden” and value=12345678.
Set the forms method-attribute to the value “GET” (actually the default value) and test the form. Observe
what happens in your browser's address field.
Change the forms method-attribute to the value “POST” and test the form. Observe the change in your
browsers address field. Figure out (using Chrome Developer Tools), how parameters are passed in, for a
POST request.
Write down your observations
Metoden GET angiver key values i den indtastede url.
Ved at bruge metoden POST fremvises kun det # som vi angav i form actionen i url’en.
Under NETWORK -> HEADERS kan man se en FORM DATA (et dokument), efter alle headers, hvori alle key
values ligger.
a. Enter SessionDemo as the name of the Servlet and servlets as package name
b. Right click the file and select Run to see “what is does”
c. Change the generated processRequest(..) method as sketched below.
d. Enter your name and press submit, copy the URL in the browser into your clipboard, close the
tab (but not the browser) and load the page again in a new tab using the URL in the clipboard.
e. While doing the things in step d, you should monitor the content of your local
cookies and the HTTP requests being sent, using the development tools in Chrome.
f. Most import part of this exercise:
Explain (on paper) using both words and images how the Server can maintain state between
subsequent calls even when the state is not transmitted from the client to server.
Når Martin indtastes bliver der genereret en sessioncookie og state står på keep alive. Nu ligger den
sessioncookie på computeren og hver gang vi taster en ny URL med
http://localhost:8080/CookieExercise/SessionDemo?name=Martin så kan vi se under cookies at der
requestes en cookie, men der genereres ikke en ny. Derved gemmes vores session i en sessioncookie.
d. Enter your name and press submit, copy the URL in the browser into your clipboard, close the
tab (but not the browser) and load the page again in a new tab using the URL in the clipboard.
e. Now close your browser (you could even close your laptop, but don’t ;-) , open it
again and load the page again using the URL in the clipboard
f. While doing the things in step e, you should monitor the content of your local
cookies and the HTTP requests being sent, using the development tools in Chrome.
g. Most import part of this exercise:
h. Explain (on paper) how Cookies can be used to maintain “state” on the client
between subsequent calls to a server, even when a browser has been closed down.