Skip to content

Commit

Permalink
Update labreport2.md
Browse files Browse the repository at this point in the history
  • Loading branch information
azuk132435 authored Nov 3, 2023
1 parent de3ed07 commit 5c679e4
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions labreport2.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@

Note:For the code for StringServer I copied NumberServer and made adjustments, code is not all by myself.<br>

In both line 1 and line 2 the methods that are called are: for starters the main method, as it creates the server checking for port number for the server to even work. They both use handleRequest in StringHandler which is the code that actually deals with
what is added after the port which here we had /add-message. It then appends the message into the messages StringBuilder. Which it then returns messages.toString. <br>
For the first screenshot first in the just Hello line the methods that are called are: the main method, creating the serving checking the port number, and then handleRequest in StringHandler, which is what deals with the code that is added after the port
using /add-message?s="whatever it is that you type". When this happens the message after s is appended onto the String in which the counter is also printed in messages.append. Here after the first run message count would increment from 0 to 1, hence it returns
1. Hello. <br>
For the second screenshot with both 1. Hello and 2.How are you, this time we aren't rerunning the main method code since the server is already running, we are simply adding a new message to this. So the main method is not run as it would reset the inputs. Then handleRequest
in StringHandler once again is used in which it checks for a message that is added on to ?s= which in this case would be How are you. This is now added to the stringbuilder along with the count incremented by (now becoming 2) and ultimately it returns it on
the next line. This leaves the output 2. How are you, below the previous output of 1. Hello. <br>

For the main method the relevant arguments was args[0] in which we inputed our port number, for int port(this happens in the terminal
when we make the server). In handleRequests: we had url which was what was inputed when we typed our link to view the server and prompt that we wanted to add text lines.
Messages took on the values of what we added after s =, which was effectively whatever word or line we wanted to add to our server/website.
Count started off as 0, naturally and the values relevence was it counted the number of inputs which allowed us to numerically number
each line based off when they were inputed.<br>
each line based off when they were inputed. This holds true for both methods, with the only difference really being that if there are multiple inputs you naturally don't want to reset and re-run the main method, otherwise previous input is lost. <br>

In terms of what changes between the two lines for the two lines for starters is the URI as we fundamentally inputed different
inputs when typing (hello vs how are you at the end). Also I want to mention that String[] parameters was used to take in the values of s and then what you wanted to input
Expand Down

0 comments on commit 5c679e4

Please sign in to comment.