Workshop Lab 1 - Going public - Online
Plan for the workshop
What we aim to do during this workshop is to set up a network in the class room and have you connect to that WIFI-network. Being on the same network, means that you can access each other's computers if they are running e.g. a web server etc.
This allows us to start a web api with the Systembolaget products on one computer, and from another computer connect to it and request the JSON with products.
So far, you have only run the servlet on your own computer and used your own computer to connect to it. We appreciate that this is rather confusing and seems weird and pointless. Therefore, we want to show you how a web api typically sits on one computer and is accessed by many clients over a network (typically the WWW and internet).
We hope that this will give you a better understanding of the purpose of the Exposing data over HTTP assignments - and give you a feel of how things work in the real world.
Connect to juneday-1
The teachers will provide the very secret password for the juneday-1 wlan. It is important that you are connected to the same network for reasons we'll discuss during the workshop. If you are on different networks (on different wlan-routers), you will not be able to contact each other's computers.
Finding out your IP number
First we'll discuss what an IP number is, and some special IP numbers. Next, we'll ask you to figure out what IP number you got from juneday-1.
We'll leave this as an exercise for the students (using google or whatever). If they can't figure it out, we'll give them some hints.
Some special IP numbers:
Private networks (not on the internet):
- 10.0.0.0 - 10.255.255.255 (16 777 216 addresses)
- 172.16.0.0 - 172.31.255.255 (1 048 576 addresses)
- 192.168.0.0 - 192.168.255.255 (65 536 addresses)
- 127.0.0.1 (localhost)
- x.x.x.255 (local net broadcast)
- x.x.x.0 (with netmask 255.255.255.0)
There's also a list of assigned IP numbers. See wikipedia for the list.
Start your web apis (run the servlet on your computer
Now, when we know each other's IP numbers, we can request some products from one another, by pointing our browsers to a friend's IP number.
Let's make the Servlet a little more interesting
As the first statements of your doGet() method in the servlet, add the following:
System.out.println("Got query from: " + request.getRemoteAddr() + "/" + request.getRemoteHost() + " using " + request.getHeader("user-agent"));
We'll discuss what this means during the workshop.
Connect again and watch your serlvet output
Now you can see who is connecting to the Servlet. Can you figure out how to also print the query string?
Spoofing the user-agent
We'll show you how easy it is to pretend to be using a special browser by spoofing the User-Agent header, using telnet.
- 09:15 - 09:30 - Introduction and discussion - the teachers show graphically what the network looks like
- 09:30 - 10:00 - Connect to the new wireless network, make sure it works
- 10:15 - 11:00 - What is an IP number? How do you figure out your IP number?
- 11:15 - 12:00 - Setting up your web apis, connecting to one and other
- 12:00 - 13:15 - LUNCH
- 13:15 - 15:00 - Some more network experiments, discussion and summary